Page 1 of 1

PNG and JPG not in the supported formats

Posted: 2015-02-12T10:05:35-07:00
by WhiteCastle
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!

Re: PNG and JPG not in the supported formats

Posted: 2015-02-12T10:52:47-07:00
by fmw42
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.

Re: PNG and JPG not in the supported formats

Posted: 2015-02-12T11:42:35-07:00
by snibgo
"type -a convert" is Unix (or Cygwin).

For Windows, use "where convert".

Posted: 2015-02-12T12:29:30-07:00
by WhiteCastle
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.

Re: PNG and JPG not in the supported formats

Posted: 2015-02-12T12:39:17-07:00
by Bonzo
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?

Re: PNG and JPG not in the supported formats

Posted: 2015-02-12T13:01:18-07:00
by WhiteCastle
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();
?>

Re: PNG and JPG not in the supported formats

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

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.

Re: PNG and JPG not in the supported formats

Posted: 2015-02-12T13:11:37-07:00
by fmw42
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.

Re: PNG and JPG not in the supported formats

Posted: 2015-02-12T13:12:08-07:00
by Bonzo
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.

Re: PNG and JPG not in the supported formats

Posted: 2015-02-12T14:43:05-07:00
by WhiteCastle
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?

Re: PNG and JPG not in the supported formats

Posted: 2015-02-12T16:02:27-07:00
by fmw42
Sorry, I am not a Windows user. Hopefully, someone else can answer that for you.

Re: PNG and JPG not in the supported formats

Posted: 2015-02-12T20:35:50-07:00
by WhiteCastle
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.

Re: PNG and JPG not in the supported formats

Posted: 2015-02-12T21:09:52-07:00
by fmw42
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.

Re: PNG and JPG not in the supported formats

Posted: 2015-02-14T05:37:19-07:00
by WhiteCastle
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.