Jump to content

[PS 1.6.0.6] Poor Quality on Uploaded Images


Recommended Posts

Hi!

 

I noticed a drop in quality while uploading images to PS 1.6.0.6 via the uploader. Is this a known issue with PS 1.6.0.6 or should I be looking somewhere else?

 

I'll post up some comparison images later in the day, but any input for now would be good!

Edited by hideaki (see edit history)
Link to comment
Share on other sites

My image settings are as follows:

 

Image Quality: Use PNG only if the base image is in PNG format.

JPEG Quality: 99

PNG Quality: 1

 

I have also tried different options for Image Quality, but apparently they still look slightly similar with loss of quality after Image Regeneration.

 

Here are 2 comparison pictures for reference:

 

http://i.imgur.com/qErZtVE.png

 

http://i.imgur.com/2w9vAv0.png

Link to comment
Share on other sites

Does this happen when you re-upload your image with the png set to zero? I'm not sure PS holds an exact copy. You may need to set png to "0" and re-upload your image.

 

>>No one else is suffering this problem?          

 

Keep in mind that like most PHP apps, PS is using the image processing routines that are built into the PHP installed on your server.

 

Couple more things ... are you uploading .png files? If so please save a copy in high quality .jpg and upload that, again make sure png is "0".

 

Thanks.

Edited by Bill Dalton (see edit history)
Link to comment
Share on other sites

Bill knows much more than I do on the PHP end so I would go with his suggestions.

I did notice that the original image size is 1000 x 1500 and Your Image block is 391 x 586

If you scale down the original image with constrained proportions is would actually be 391 x 587

I am not so sure the extra pixel would make a discernible difference but with what Bill mentioned on how PHP apps handle images, perhaps it's enough to cause a slight loss in quality.

Link to comment
Share on other sites

Does this happen when you re-upload your image with the png set to zero? I'm not sure PS holds an exact copy. You may need to set png to "0" and re-upload your image.

 

>>No one else is suffering this problem?          

 

Keep in mind that like most PHP apps, PS is using the image processing routines that are built into the PHP installed on your server.

 

Couple more things ... are you uploading .png files? If so please save a copy in high quality .jpg and upload that, again make sure png is "0".

 

Thanks.

 

Hi Bill, many thanks for your replies. I have removed the original image, set the PNG Quality to 0, and uploaded a new copy. However, I'm still seeing a drop in quality on the uploaded image. If you notice, there is a difference in color as well. You can see it here: http://i.imgur.com/rTVuwQO.png

 

Do you mean that this could possibly be the problem of the PHP installed on the server? If so, what should I check with my web host about?

 

Currently, I am uploading images as .png files, I will do as per your suggestion and we'll see how it goes. Do we still keep Image Quality as " Use PNG only if the base image is in PNG format."? I have also set JPEG Quality to 100.

Link to comment
Share on other sites

From what I can tell by looking at the code, PS only names the images with a jpg extension, but it actually uses png as the file format because it is can be loss less. So basically when you upload a jpg file it converts it to png but doesn't change the extension.

 

You can see this very well, note the size a jpg file before you upload, next look at the size of the file after PS uploads the image. It will be much larger. You can see the directory each image is stored in when you are in Catalog  > Products  > Images, just hold your mouse over an image to see where it is located on disk.

 

Yes, keep the Use PNG only if the base image is in PNG format.

Link to comment
Share on other sites

Hi Bill,

 

I have tried saving the image as a JPG file in max quality, but I'm still pretty much getting the same results.

 

I have uploaded the comparison here: http://i.imgur.com/3F9qi13.png

 

The left image is the original image resized to 391px x 587px and the right image is the image uploaded to PS. Do you notice the difference between them? The left image looks sharper than the uploaded image.

 

In the meantime, I am also checking with the web host with regards to this.

 

Do let me know if  you have any other ideas. Thanks!

Link to comment
Share on other sites

I currently am using PS 1.5.6.2.

 

I installed the latest version last night PS 1.6.0.8 and I can confirm that it blurred the images. I'm surprised we are not hearing more about this. It is probably because in most cases the blurred image isn't that noticeable. But in your case you can clearly see the difference.

 

I don't think it is your host. There may be a problem here. If you could make a couple of your images available on your sever, that have not been processed by PS I's like to try a few tests. Could you do that for me and post the links ...

Link to comment
Share on other sites

Any news on this? I am having the same issue. I switched to uploading PNG's, but they are way to heavy (size is increased by 3 times because of the upload).

 

I checked /classes/ImageManager.php and on line 142 it actually says:

 

JPG reencoding by GD, even with max quality setting, degrades the image

 

Then why not switch to a different PHP library???

Edited by connectcase (see edit history)
Link to comment
Share on other sites

I think it's because most shared hosting do not enable/install ImageMagick by default.

 

Like for my case, it took me a pain to get my web host to enable ImageMagick. I'm going to try overriding the code to see if ImageMagick works better, and will post my findings here.

Link to comment
Share on other sites

Did some hacking (overriding) to ImageManager.php using ImageMagick for the resizing instead of the crappy GD library. 

 

And here's the results: http://imgur.com/JJ7HtUc

 

Image on the left is the original image (1000px x 1500px) resized to 391px x 587px via PhotoShop, while the one on the right was done with ImageMagick. 

 

What do you guys think?

Link to comment
Share on other sites

Agreed. I would like to see the code as well!

 

Sure, here's my code for the resize() function in ImageManager. Do ensure that ImageMagick is enabled on your server!

	/**
	 * Resize, cut and optimize image
	 *
	 * @param string $src_file Image object from $_FILE
	 * @param string $dst_file Destination filename
	 * @param integer $dst_width Desired width (optional)
	 * @param integer $dst_height Desired height (optional)
	 * @param string $file_type
	 * @return boolean Operation result
	 */
	public static function resize($src_file, $dst_file, $dst_width = null, $dst_height = null, $file_type = 'jpg', $force_type = false, &$error = 0)
	{
		if (PHP_VERSION_ID < 50300)
			clearstatcache();
		else
			clearstatcache(true, $src_file);
		
		if (!file_exists($src_file) || !filesize($src_file))
			return !($error = self::ERROR_FILE_NOT_EXIST);

		list($src_width, $src_height, $type) = getimagesize($src_file);

		// If PS_IMAGE_QUALITY is activated, the generated image will be a PNG with .jpg as a file extension.
		// This allow for higher quality and for transparency. JPG source files will also benefit from a higher quality
		// because JPG reencoding by GD, even with max quality setting, degrades the image.
		if (Configuration::get('PS_IMAGE_QUALITY') == 'png_all'
			|| (Configuration::get('PS_IMAGE_QUALITY') == 'png' && $type == IMAGETYPE_PNG) && !$force_type)
			$file_type = 'png';

		if (!$src_width)
			return !($error = self::ERROR_FILE_WIDTH);
		if (!$dst_width)
			$dst_width = $src_width;
		if (!$dst_height)
			$dst_height = $src_height;

		//$src_image = ImageManager::create($type, $src_file);
		
		$src_image = new Imagick($src_file);

		$width_diff = $dst_width / $src_width;
		$height_diff = $dst_height / $src_height;

		if ($width_diff > 1 && $height_diff > 1)
		{
			$next_width = $src_width;
			$next_height = $src_height;
		}
		else
		{
			if (Configuration::get('PS_IMAGE_GENERATION_METHOD') == 2 || (!Configuration::get('PS_IMAGE_GENERATION_METHOD') && $width_diff < $height_diff))
			{
				$next_height = $dst_height;
				$next_width = round(($src_width * $next_height) / $src_height);
				$dst_width = (int)(!Configuration::get('PS_IMAGE_GENERATION_METHOD') ? $dst_width : $next_width);
			}
			else
			{
				$next_width = $dst_width;
				$next_height = round($src_height * $dst_width / $src_width);
				$dst_height = (int)(!Configuration::get('PS_IMAGE_GENERATION_METHOD') ? $dst_height : $next_height);
			}
		}

		if (!ImageManager::checkImageMemoryLimit($src_file))
			return !($error = self::ERROR_MEMORY_LIMIT);
			
		$dest_image = $src_image;
		$dest_image->resizeImage($dst_width, $dst_height, Imagick::FILTER_LANCZOS, 1);
		//$dest_image->writeImage('mythumb.gif');
		
		//$dest_image->destroy(); 
		
		//$dest_image = imagecreatetruecolor($dst_width, $dst_height);

		// If image is a PNG and the output is PNG, fill with transparency. Else fill with white background.
		/*if ($file_type == 'png' && $type == IMAGETYPE_PNG)
		{
			imagealphablending($dest_image, false);
			imagesavealpha($dest_image, true);
			$transparent = imagecolorallocatealpha($dest_image, 255, 255, 255, 127);
			imagefilledrectangle($dest_image, 0, 0, $dst_width, $dst_height, $transparent);
		}
		else
		{
			$white = imagecolorallocate($dest_image, 255, 255, 255);
			imagefilledrectangle ($dest_image, 0, 0, $dst_width, $dst_height, $white);
		}*/

		/*imagecopyresampled($dest_image, $src_image, (int)(($dst_width - $next_width) / 2), (int)(($dst_height - $next_height) / 2), 0, 0, $next_width, $next_height, $src_width, $src_height);*/
		//return (ImageManager::write($file_type, $dest_image, $dst_file));
		return $dest_image->writeImage($dst_file);
	}
  • Like 3
Link to comment
Share on other sites

  • 1 month later...
×
×
  • Create New...