Saving file with different extension

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
arron

Saving file with different extension

Post by arron »

Hi,
i need to solve problem, when i read image (jpg for example) and i want to write it as a jpeg in to file with different extension (tmp).
I tried:

Code: Select all

$im = new Imagick;
$im->readImage('30062007038.jpg');
$im->setImageFilename('aa.tmp');
$im->setImageFormat('jpeg');
$im->writeImage();
but i get exception:

Fatal error: Uncaught exception 'ImagickException' with message 'no encode delegate for this image format `aa.tmp'' in test.php:33 Stack trace: #0 test.php(33): Imagick->writeimage() #1 {main} thrown in test.php on line 33


Is there any chance to do this??
thx for any help.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Saving file with different extension

Post by magick »

TMP has a special meaning in ImageMagick. Saving to aa.abc for example works. To get around the problem, use a filename of jpeg:aa.tmp.
arron

Re: Saving file with different extension

Post by arron »

I maybe doing something wrong:

Code: Select all

$im->writeImage('jpeg:aa.tmp');
i'm still getting the same exception:-(
Post Reply