Page 1 of 1

Reduce image quality problem

Posted: 2008-06-23T01:32:32-07:00
by Jotun
I am using PHP and the .dll in a windows server at the moment, and I have large 80mb .tiff images that I have managed to scale down to around 500x500 jpegs. They still take up around 600kb of disk space however, which is not suitable for the web. The images are at 300 dpi and I need them to be reduced in quality and dpi to around 50-60kb and 72 dpi. The problem is that I have not found a function in the API that can do these things. Does it only work from the command prompt?

I have tried a lot of functions that seem to be almost exactly the same:

Code: Select all

MagickResampleImage($resource, 500, 280, MW_GaussianFilter, 1);
MagickResizeImage($resource, 500, 280, MW_GaussianFilter, 1);
MagickSampleImage($resource, 500, 280); <---Best quality 
MagickScaleImage($resource, 500, 280);	
MagickSetImageResolution($resource, 500, 280); <-- no effect?
MagickSetResolution($resource, 500, 280); <-- no effect?
I am aware that this only stretches the images and does not actually change the quality, in fact even if I set the x and y to 50x50, the image file still takes up the same amount of disk space. Please help me reduce the disk size and quality to something similar to what "Save for Web" does in Photoshop. Thanks!

Re: Reduce image quality problem

Posted: 2008-06-23T01:44:43-07:00
by Jotun
This is the code I use:

Code: Select all

set_time_limit( 60 * 5 ); 
	$resource = NewMagickWand();
	
	MagickReadImage( $resource, 'images_upload/22XS13.tif' );
	MagickSetImageFormat($resource, 'JPEG');	
	
	MagickSetImageDepth($resource, 8);	
	MagickSetCompressionQuality($resource, 60);
	 
	$resource = MagickTransformImage($resource, '0x0', '500x280');	
	MagickWriteImage($resource, 'images_unedited/22XS13.jpg');
	header('Content-Type: image/jpeg'); 
	MagickEchoImageBlob($resource);

Re: Reduce image quality problem

Posted: 2008-07-02T06:30:25-07:00
by jsaints
I am having the exact same issue here. When I create JPG files from tif files, the files size is too large for the web. Any progress on this one?

The best I have been able to do is take a 8Mb tif down to a 279k png file. This is not as good as photoshop's 44k for the same image.

Here is the code i am using:

Code: Select all

 convert -resample 72 081W0203.tif -filter Lanczos -depth 8 -antialias -quality 85 -thumbnail 480 test.png

Re: Reduce image quality problem

Posted: 2008-07-02T08:24:04-07:00
by jsaints
I figured it out...

This code seems to make images about the same size/quality as photoshop "Save for Web"

Code: Select all

 convert -resample 72 -filter Lanczos -depth 8 -antialias -quality 60 -thumbnail 480 strings_MG_8855.tif test.jpg
The difference was use JPG for output image instead of PNG.