Page 1 of 1

how to create a Interlace / Progressive image

Posted: 2007-08-26T12:59:13-07:00
by micsky
I have tried with no luck in creating an interlaced / progressive JPEG image using the Imagick extension. Per the manual I should be able to user bool Imagick::setImageInterlaceScheme ( int $interlace_scheme ) however I haven't had any luck with it.

Here is what I have so far:

$image = new Imagick();
$image->readImage('flower.jpg');
$image->scaleImage(0,1024);
$image->setCompressionQuality(87);

//I do not know what $interlace_scheme settings are,
//and have tried every integer from 0-10 as the interlace_scheme.
$image->setImageInterlaceScheme(0);
header('Content-type: image/jpeg');
echo $image;

If anyone knows how to use, please let me know. Thanks

Re: how to create a Interlace / Progressive image

Posted: 2007-08-27T05:36:42-07:00
by mkoppanen
http://php.net/manual/en/imagick.constants.php search for Interlace constants

you need to pass something like $im->setImageInterlaceScheme( imagick::INTERLACE_PARTITION );

--
Mikko Koppanen

Re: how to create a Interlace / Progressive image

Posted: 2007-09-01T14:42:18-07:00
by micsky
Thanks for the response.

I just got around to trying this, but with my luck it's not working.
I have tried it in the same order as function calls are above.
Also tried every constant available:

$image->setImageInterlaceScheme( imagick::INTERLACE_UNDEFINED );
$image->setImageInterlaceScheme( imagick::INTERLACE_NO);
$image->setImageInterlaceScheme( imagick::INTERLACE_LINE );
$image->setImageInterlaceScheme( imagick::INTERLACE_PLANE );
$image->setImageInterlaceScheme( imagick::INTERLACE_PARTITION );

At least I don't get any errors (except I'm not catching exceptions).
But unfortunately images are still being displaying top down, rather then progressively loading into the browser.

Any further help would be appreciated.
-mfg

Re: how to create a Interlace / Progressive image

Posted: 2007-09-01T18:50:06-07:00
by magick
Assume your the image you are writing is "image.jpg". Instead save it as "pjpeg:image.jpg."

Re: how to create a Interlace / Progressive image

Posted: 2007-09-01T19:23:55-07:00
by mkoppanen
That worked here!

<?php

/* Create a new object and read the image in */
$im = new imagick( "/var/www/testimages/new/im/strawberry.jpg" );

/* Set format and interlace scheme */
$im->setImageFormat( "pjpeg" );
$im->setImageInterlaceScheme( imagick::INTERLACE_LINE );

/* Output */
header( "Content-Type: image/pjpeg" );
echo $im;

?>

Re: how to create a Interlace / Progressive image

Posted: 2007-09-06T19:59:26-07:00
by micsky
Thanks for the posts all.

It seems to be working, but for some reason I'm only getting the image displaying all at once (not loading in stages). I know my browser is capable of progressive images, but I guess I'm just have to keep playing with it.

Cheers, -mfg

Re: how to create a Interlace / Progressive image

Posted: 2007-09-08T16:49:27-07:00
by ridera
Read your image into an image editor, Photoshop, Paintshop Pro, etc. and use its image info feature.

Re: how to create a Interlace / Progressive image

Posted: 2010-07-09T08:34:10-07:00
by jaclyn-hv
Hello,

I seem to be having trouble with setImageInterlaceScheme on newer versions of imagick. I have tried everything as suggested in this thread but the function seems to do nothing still. Here is my imagick version information:

About pecl.php.net/imagick-2.3.0
================================
Release Type PECL-style PHP extension (source code)
Name imagick
Channel pecl.php.net
Summary Provides a wrapper to the ImageMagick library.
Description Imagick is a native php extension to create and
modify images using the ImageMagick API.
This extension requires ImageMagick version
6.2.4+ and PHP 5.1.3+.

IMPORTANT: Version 2.x API is not compatible
with earlier versions.
Maintainers Mikko Koppanen <mkoppanen@php.net> (lead)
Scott MacVicar <scottmac@php.net> (lead)
Release Date 2009-07-28 11:06:14
Release Version 2.3.0 (stable)
API Version 2.3.0 (stable)
License PHP License (http://www.php.net/license)
Release Notes - imagick::setImageVirtualPixelMethod not
deprecated anymore
- fixed windows build
Required Dependencies PHP version 5.1.3
PEAR installer version 1.4.0 or newer
package.xml version 2.0
Last Modified 2010-06-24 14:21
Previous Installed - None -

I cannot find any documentation that says whether this function is or is not working with this version. Can anyone help?