bad quality imagecopy() output

images php coding issues or problems here.

Moderators: macek, egami, gesf

sergio_mi
New php-forum User
New php-forum User
Posts: 23
Joined: Thu Apr 22, 2004 7:00 am

bad quality imagecopy() output

Postby sergio_mi » Mon May 17, 2004 5:05 am

I'm trying to create a jpeg image summing some png with alpha0 background, but the result is not perfect. the image seems to be composed by stripes that don't match perfectly.
the code is:
<?php
header("Content-type: image/jpeg");
$png1= $_GET['png1'];
$png2= $_GET['png2'];
$png3= $_GET['png3'];
$png4= $_GET['png4'];
$png5= $_GET['png5'];

$im1 = imagecreatefromjpeg("images/background.jpg");
//background image
$im2 = imagecreatefrompng("images/$png1.png");
$im3 = imagecreatefrompng("images/$png2.png");
$im4 = imagecreatefrompng("images/$png3.png");
$im5 = imagecreatefrompng("images/$png4.png");
$im6 = imagecreatefrompng("images/$png5.png");
ImageCopy($im1,$im2,0,0,0,0,608,300);
ImageCopy($im1,$im3,0,0,0,0,608,300);
ImageCopy($im1,$im4,0,0,0,0,608,300);
ImageCopy($im1,$im5,0,0,0,0,608,300);
ImageCopy($im1,$im6,0,0,0,0,608,300);
imagejpeg($im1,'',100); // set to best quality
imagedestroy($im1);
imagedestroy($im2);
imagedestroy($im3);
imagedestroy($im4);
imagedestroy($im5);
imagedestroy($im6);
?>
jpeg and png have same dimensions

sergio_mi
New php-forum User
New php-forum User
Posts: 23
Joined: Thu Apr 22, 2004 7:00 am

solution

Postby sergio_mi » Mon May 17, 2004 5:14 am

if you create an image (ex: 600 x 300) don't specify width and height in your img tag.

<img src="imageCreator.php" border=0>

User avatar
swirlee
Moderator
Moderator
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Re: bad quality imagecopy() output

Postby swirlee » Mon May 17, 2004 11:05 am

(FYI, the above post probably won't solve any of your problems. )

sergio_mi wrote:the image seems to be composed by stripes that don't match perfectly


I"m not sure what you mean, here. Could you show us an example?

User avatar
ruturajv
php-forum Super User
php-forum Super User
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India
Contact:

Postby ruturajv » Mon May 17, 2004 7:40 pm

I think that the original image which is being copied is heavily compressed and hence the output is bad.

sergio_mi
New php-forum User
New php-forum User
Posts: 23
Joined: Thu Apr 22, 2004 7:00 am

i've solved my problem

Postby sergio_mi » Tue May 18, 2004 7:29 am

Hi, let me explain...
I had to generate a jpeg dynamically from a set of png (each containing a part of the total image), accordingly to user's choice in page pageA.php

pageA.php generates pageB.html above all the tag
<img scr="generator.php?var=x&var2=y(var choiced by the user in pageA.php)" width=608 height=300 /> to display the jpeg

The img tag in pageB.html calls for generator.php.
I wrote the code for the generator.php in my first post.
generator.php generates the jpeg width=608 height=300.

As I already wrote at the beginnig the jpeg was displayed like formed by stripes badly aligned (with 1 or 2 pixels of ditorsion).

As I wrote the image tag in pageB.html without width and height the problem disappered.

don't know why or how but now everything works, efficently.
I swear I haven't changed nothing in the generator.php page.

answering to ruturajv the output now is wonderfull, even setting the quality to 80.

thanks

User avatar
ruturajv
php-forum Super User
php-forum Super User
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India
Contact:

Postby ruturajv » Tue May 18, 2004 7:44 pm

i think you were using ie or mozilla firefox

they resize the image to fit the screen and hence producing the kind of quality that you've mentioned...

you must have watched the generator page directly... !!! :-D :-D


Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 1 guest