PNG and JPG not in the supported formats

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
WhiteCastle
Posts: 6
Joined: 2015-02-11T15:16:58-07:00
Authentication code: 6789

PNG and JPG not in the supported formats

Post by WhiteCastle » 2015-02-12T10:05:35-07:00

Hi!

I'm using the latest version of IM and dependencies and works fine in Command Prompt (MS DOS) and I can manipulate JPG, PNG and others. But in PHP some things go wrong, JPG and PNG doesn't shows up in the Supported Formats, I tried to manipulate others formats in PHP like BMP and GIF and it works fine, but with JPG and PNG doesn't, I receive a Fatal Error with no description, which the reason, i believe be the some libraries not readable/installed/working in PHP.
I need those libraries working. So what do i have to do?

In the PHPINFO(), you can see there are no JPG and PNG formats in the list.

Image

convert -list configure

This command results about ImageMagick, and it says that he delegates PNG and JPG as well, and as i said, It really works on Command Prompt but the problem is in Apache or PHP, I dont know.

I've copy and paste all libraries DLL and CODE_RL* to the right directory.
Path: [built-in]

Name Value
-------------------------------------------------------------------------------
FEATURES OpenMP
NAME ImageMagick
QuantumDepth 16

Path: C:\ImageMagick\configure.xml

Name Value
-------------------------------------------------------------------------------
CC vs10
COPYRIGHT Copyright (C) 1999-2014 ImageMagick Studio LLC
DELEGATES bzlib freetype jpeg jp2 lcms png tiff x11 xml wmf zlib
FEATURES OpenMP
HOST Windows
LIB_VERSION 0x690
LIB_VERSION_NUMBER 6,9,0,5
NAME ImageMagick
RELEASE_DATE 2015-02-15
VERSION 6.9.0
WEBSITE http://www.imagemagick.org
--------
fmw42 wrote:This is not the same issue. You really need to post a new topic and not tack onto an old similar one. Also you should always provide your IM version and platform.

I am not a PHP expert, but have some experience.

Typically, the problem is as follows:

You need to find where IM convert resides for PHP and put the path to it before convert in your exec() command

try

type -a convert

in a terminal window.

Otherwise ask your ISP

Then use

exec("fullpath2imconvert/convert ....");

Alternately, put it in your $PATH environment variable.

Can you use a terminal window? If so, then what do you get from

convert -version

Hi fmw42,

I've tried "type -a convert" in Prompt Command MS DOS window and it result in a error message (Is it to try in Prompt Command??):
the system cannot find the file specified
Error processing: -a
the system cannot find the file specified
Error processing: convert
convert -version
Version: ImageMagick 6.9.0-5 Q16 x86 2015-01-31 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates (built-in): bzlib cairo freetype jbig jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib
Windows 7 Ultimate x64
XAMPP 5.6.3 x86
PHP: 5.6.3
APACHE 2.0 Handler
ImageMagick-6.9.0-5-Q16-x86-dll.exe
PELC IMAGICK: php_imagick-3.1.2-5.6-ts-vc11-x86.zip

Image


Sorry about the bad English.

Thank you!

User avatar
fmw42
Posts: 25256
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PNG and JPG not in the supported formats

Post by fmw42 » 2015-02-12T10:52:47-07:00

Your version looks fine. The path to the coders is not what you want.

Now you need to find the path to that IM convert. You need to open a terminal window. I think it is the CMD Window on a Windows PC and try

type -a convert

if that finds nothing, then you need to contact your ISP to find where IM convert is located. If this is on your personal system, then you will have to find it yourself. You can try Search and look for convert, but note that Windows has its own convert.exe. You need to find the IM convert and rename it to something like IMconvert.exe or just IMconvert. You can try looking in C:\Imagemagick\. There may a a bin directory containing convert?

Then

exec("fullpath2/IMconvert rose: rose.jpg");

and see if you get a resulting image, rose.jpg

I am not a Windows user, so you may get a better answer from one of the IM Windows users.

snibgo
Posts: 11910
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PNG and JPG not in the supported formats

Post by snibgo » 2015-02-12T11:42:35-07:00

"type -a convert" is Unix (or Cygwin).

For Windows, use "where convert".
snibgo's IM pages: im.snibgo.com

WhiteCastle
Posts: 6
Joined: 2015-02-11T15:16:58-07:00
Authentication code: 6789

Post by WhiteCastle » 2015-02-12T12:29:30-07:00

Thanks guys, 'where convert' worked, it show the directory:
C:\ImageMagick\convert.exe
C:\Windows\System32\convert.exe
but rename the convert.exe dont affected in the number of Suported Formats in PHPINFO(), is there another step?

I was thinking about use exec() to convert all the JPG and PNG into BMP... then work on it with PHP, export it to BMP, and then use exec() again to convert to JPG or PNG. But that is not normal and probaly will take more time to process the code ... and i will lose all the ALPHA CHANNEL converting to bmp.

Bonzo
Posts: 2970
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: PNG and JPG not in the supported formats

Post by Bonzo » 2015-02-12T12:39:17-07:00

I was thinking about use exec() to convert all the JPG and PNG into BMP... then work on it with PHP
exec() is php why not use it for the whole process?

WhiteCastle
Posts: 6
Joined: 2015-02-11T15:16:58-07:00
Authentication code: 6789

Re: PNG and JPG not in the supported formats

Post by WhiteCastle » 2015-02-12T13:01:18-07:00

Let's try a small example doing this

This code works if i use a BMP or GIF, but not with JPG and PNG, how can i work on this simple code using exec?
<?php
$im = new Imagick();
$im->readImage( realpath('test.jpg') );
$im->thumbnailImage( 100, null );
$im->writeImage( 'th_test.jpg' );
$im->destroy();
?>

Bonzo
Posts: 2970
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: PNG and JPG not in the supported formats

Post by Bonzo » 2015-02-12T13:08:18-07:00

Code: Select all

exec("convert test.jpg -thumbnail 100x100 th_test.jpg");
I am not sure what realpath() is but you can use variables in your code as well.

User avatar
fmw42
Posts: 25256
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PNG and JPG not in the supported formats

Post by fmw42 » 2015-02-12T13:11:37-07:00

Imagick is different from using PHP exec(). You should choose which one you want to use. But note that Imagick is not as full-featured as exec() running IM command lines.

The Imagemagick version and especially what delegates are linked may be different for Imagick and your version of Imagemagick.

Bonzo
Posts: 2970
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: PNG and JPG not in the supported formats

Post by Bonzo » 2015-02-12T13:12:08-07:00

I should say in the case above Imagick if it was working would probably be faster than exec().

Imagick can be a pain to install and you are limited to the options built into Imagick whereas using exec() you can use any of the options available in Imagemagick. As fmw42 states above.

WhiteCastle
Posts: 6
Joined: 2015-02-11T15:16:58-07:00
Authentication code: 6789

Re: PNG and JPG not in the supported formats

Post by WhiteCastle » 2015-02-12T14:43:05-07:00

I did read a post where some guy found a solution, just installing manually the libraries

In this topic:
http://www.webmasterworld.com/php/3857215.htm

Here's a quote of his post, looks like the same problem:
EDIT: Wow. Just wow. I specifically tried .gif last evening, but it was one of those situations where you try multiple things and get lost in what you've tried. I used a full path (/var/www/html/....image) and it wasn't working. Setting it without a path, worked with .gif (thought I'd already tried that . . . )

It works with .gif, .bmp, but not .jpg or .png, which are not in my list of supported formats. So now I have to figure out why that is . . . almost there!
After that, he post where he found the solution with the step-by-step:

viewtopic.php?p=41710#p41710

The problem: Its on MAC and i can't understand this ways.

Installing these missing libraries manually on the PHP/APACHE is the only solution?? How can i do this on Windows?

User avatar
fmw42
Posts: 25256
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PNG and JPG not in the supported formats

Post by fmw42 » 2015-02-12T16:02:27-07:00

Sorry, I am not a Windows user. Hopefully, someone else can answer that for you.

WhiteCastle
Posts: 6
Joined: 2015-02-11T15:16:58-07:00
Authentication code: 6789

Re: PNG and JPG not in the supported formats

Post by WhiteCastle » 2015-02-12T20:35:50-07:00

Bonzo wrote:

Code: Select all

exec("convert test.jpg -thumbnail 100x100 th_test.jpg");
I am not sure what realpath() is but you can use variables in your code as well.
It works good, but I want to use full features.

I will create a PHP routine like:

1 - Open a PSD file, identify and separate all layers
2 - Gave by a variable a new content to text layers
3 - Include a JPG or PNG with alpha channel file
4 - Export it in PNG format

Will I be able to do all this with exec()?
fmw42 wrote:Sorry, I am not a Windows user. Hopefully, someone else can answer that for you.
I really hope that!! haha thank you.

User avatar
fmw42
Posts: 25256
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PNG and JPG not in the supported formats

Post by fmw42 » 2015-02-12T21:09:52-07:00

You may be able to do it with Imagick. You should be able to do it with one or more exec() commands. Imagick has not kept up with many of the latest enhancements to Imagemagick and is lacking some older ones.

Some PSD files have layer types with which Imagemagick cannot deal. Simple layers should be fine.

WhiteCastle
Posts: 6
Joined: 2015-02-11T15:16:58-07:00
Authentication code: 6789

Re: PNG and JPG not in the supported formats

Post by WhiteCastle » 2015-02-14T05:37:19-07:00

fmw42 wrote:You may be able to do it with Imagick. You should be able to do it with one or more exec() commands. Imagick has not kept up with many of the latest enhancements to Imagemagick and is lacking some older ones.

Some PSD files have layer types with which Imagemagick cannot deal. Simple layers should be fine.

Thank you for the answer, is good to know about that. I will keep trying to find a better way to start my project.

Post Reply