Hiya,
I got some really strange things going on. This is one of my first attemps using GD Library for picture manipulation.
Well, what I want to do is to have a user upload a picture. It gets then resized and merged with a common background.
The problem I encounter is that if that background picture is a PNG it looks at the end really bad.
If the background picture is a JPEG, then the uploaded picture looses quality.
Ok, this isn't protected yet at all since I'm still working on it.
Here is the necessary info:
Background Pics:
http://www.montepacis.com/members/add_member/background.jpg
http://www.montepacis.com/members/add_member/background.png
File Upload Formular:
http://www.montepacis.com/members/add_member/
resp.: http://www.montepacis.com/members/add_member/index.php
==> Required fields are: Status / Vulgo and both Passwort fields
File Upload must be JPEG!!!
Here's the code I use for the resizing and saving:
$src = ImageCreateFromJPEG("$picture" );
$org_h = imagesy($src );
$org_w = imagesx($src );
if($org_h > $org_w ) {
$cfg[height] = 150;
$cfg[width] = floor($cfg[height] $org_w / $org_h );
$cfg[dstX] = 90 - ($cfg[width] 0.5);
$cfg[dstY] = 15;
} else {
$cfg[width] = 150;
$cfg[height] = floor($cfg[width] $org_h / $org_w );
$cfg[dstX] = 15;
$cfg[dstY] = 90 - ($cfg[height] 0.5);
}
$img = ImageCreateFromPNG("background.png");
ImageCopyResized($img, $src, $cfg[dstX], $cfg[dstY], 0, 0, $cfg[width], $cfg[height], $org_w, $org_h );
$path_temp1 = $path_temp."_1.jpg";
ImageJPEG($img, $path_temp1, 100 );
$img = ImageCreateFromJPEG("background.jpg");
ImageCopyResized($img, $src, $cfg[dstX], $cfg[dstY], 0, 0, $cfg[width], $cfg[height], $org_w, $org_h );
$path_temp2 = $path_temp."_2.jpg";
ImageJPEG($img, $path_temp2, 100 );
Currently resized pics will be created from PNG and JPG background so that you see the difference easily.
If you upload a pic it will then be (up to now) in following directory:
http://www.montepacis.com/members/add_member/
and be named "VULGO"1.jpg resp. "VULGO"2.jpg
I don't know why these pics turn out like that. I appreciate your help on this.
Stephan