Page 1 of 1

png32:- works, png:- doesn't

Posted: 2012-08-17T05:03:33-07:00
by CodeFan
I've installed IM 6.7.9-0 from source on CentOS6.

One thing which stands out is that I have made sure I have libpng15 installed in the /usr/lib64 dir but during execution of the configuration script it shows:

Code: Select all

checking for LIBPNG15 support ... no
..which forces it to use the already present libpng12.

Then whenever i use png:- as output format a no encode delegate error is thrown. The error is only occured when executing the command without a shell environment. Also the png32:- output format works ok even without shell.

Any idea why the plain png:- output won't work for me when no shell environment is present?

Re: png32:- works, png:- doesn't

Posted: 2012-08-17T09:37:38-07:00
by glennrp
CodeFan wrote: Any idea why the plain png:- output won't work for me when no shell environment is present?
That's odd. Have you verified that the output is actually in PNG32 format?

Re: png32:- works, png:- doesn't

Posted: 2012-08-17T20:11:25-07:00
by CodeFan
glennrp, I'm not completely sure that's the case. You can see the output here:
Image
The resulting image has transparency and is returned with a Content-type: image/png so i think the browser interprets it like such.
I remember seeing somewhere that the png32:- delegate uses a different library than the png:- format. Maybe something causes the libpng library to break with no shell evironment.

Here is the base64 encoded output of the image:

Code: Select all

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABYBAMAAACDuy0HAAAAG1BMVEX+/v4BAQH///8KCgoDAwN/f3/19fWAgID8/PzhDwT2AAAACXRSTlMFBQUFBQUFBQWHDtP9AAALwklEQVR4Xg3KOWOyWhAA0Bn2ci57eXEvQY1JCZp8sQTjVoJLTAkaE0swbj/7ve4UB37FLW4q86Lwwlh86J/ASAkpWaj+Krbb31HzH0Kjc2tIl7SADaWbpZBPE5dds6jJNyNdjAyKWqdroIixWRQIY6E/kOY7hIciL/ZfrAO3XP/06AuUJ3mSd/z95OB9vIal0DPlaZWHP7RE6DIXjmKqKkuGr+xNZylOnj1GSlUKvnxZDBOIzTfMe0fJgJ7c/GIIOdUuKxYyBFUOzvY6AC5AXx8R+o5O4S0j0wqBND3ErIYm/XHFbQjtH1MXD5dUbp19OFdjkDlys+HSwrBgHRvL9wVN/pi8ViOIwcv/D1G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8X2s3+IBLIhvL8RHopoHpIArJysYTTmMMeubPXh8W760AvMVH67jqgg06+/ne5MZ631z6yROhloh3dPQirZoEpr80wgt/cEbhbAQTmRLtGh8lxCwDBBb5OeJ4aEq25XBNMT2rzWedW2zIzj+CCDKlnlyJBzT81qBWp69h7vlb3TmEV+DNm2rqj1iT7BQuwVVsuPkwq1e5P8tgNjVbIlMzwXeM11kZqjx3KKFOJzc3CAyFVhi8fxVZ5FvhdAM5mM6kS6OgKu16MFglq3/b/QVIwdw7HUCyeW04JPjC5dO+GC9OfqfB4VX+wwuift+ths2Ss3i6nkOE+JFyD+wKFL+WMX6nwwDva0S1/O8Mlnida69Ph96fuFvCoRMvXnCfsLPPmC/hA5RnMNE4fDK0pVOQ4BHLaErzv/wD99ABmjNZk0AAAAABJRU5ErkJggg==

Re: png32:- works, png:- doesn't

Posted: 2012-08-17T20:26:38-07:00
by glennrp
I examined it with "identify -verbose"
  • IHDR chunk data:
    Width=221, height=18
    Bit depth =8
    Color type=6
    Interlace =0
    Properties:
    png:IHDR.bit_depth : 8
    png:IHDR.color_type : 6 (RGBA)
The Color type (6) and Bit depth (8) are those of a PNG32.

Re: png32:- works, png:- doesn't

Posted: 2012-08-17T20:35:52-07:00
by CodeFan
Yes, that's the working png32:- delegate. When i use just png:- it throws the no encode delegate error. Here is the php code i call the convert program with:

Code: Select all


        $format = 'jpg:-';
        switch($options['format']) {
            case 'png' :
                $format = 'png32:-';
                break;
            default:
                $format = 'jpg:-';
                break;
        }

	$IMCommand = BIN_PATH.'convert ';
	$IMCommand .= '			-size '.$options['X'].'x'.$options['Y'].' ';
	$IMCommand .= '			-background transparent ';
	$IMCommand .= '			-fill white ';
	$IMCommand .= '			-stroke none ';
	$IMCommand .= '			-gravity center ';
	$IMCommand .= '			-trim ';
	$IMCommand .= '			-font '.FONTS_PATH.DIRECTORY_SEPARATOR.escapeshellarg($options['font']).' ';
	$IMCommand .= '					 label:"'.escapeshellarg($options['text']).'" ';
	$IMCommand .= '			'.$format.' ';

        $descriptorspec = array();
        switch($pipenum) {
            case 1 :
                $descriptorspec = array(
                        1 => array("pipe", "w")
                );
                break;
            case 3 :
                $descriptorspec = array(
                        0 => array("pipe", "r"),
                        1 => array("pipe", "w"),
                        2 => array("pipe", "w")
                );
                break;
            default :
                $descriptorspec = array(
                        1 => array("pipe", "w"),
                        2 => array("pipe", "w")
                );
                break;
        }
        
	$process = proc_open($IMCommand, $descriptorspec, $pipes);
        $add = '';
        $error = '';
        
        
	if (is_resource($process)) {
            if($pipenum > 2) {
                fwrite($pipes[0], $input);
                fclose($pipes[0]);
            }
            
	    while (!feof($pipes[1])) {
	        $add .= fgets($pipes[1]);
	    }
	     
	    fclose($pipes[1]);
            
            if($pipenum > 1) {
                while (!feof($pipes[2])) {
                    $error .= fgets($pipes[2]);
                }
                
                fclose($pipes[2]);
            }
	     
	    $return_value = proc_close($process);
	}

Re: png32:- works, png:- doesn't

Posted: 2012-08-17T20:42:44-07:00
by glennrp
CodeFan wrote: Then whenever i use png:- as output format a no encode delegate error is thrown. The error is only occured when executing the command without a shell environment. Also the png32:- output format works ok even without shell.

Any idea why the plain png:- output won't work for me when no shell environment is present?
I don't see anything inside coders/png.c (RegisterPNGImage(()) that would explain why
PNG32 works and PNG doesn't.

Does "convert -list delegate" give any hint?

Re: png32:- works, png:- doesn't

Posted: 2012-08-17T21:01:22-07:00
by CodeFan
Just a clarification - I tried running procopen() on a shell script using png:- for output instead of just the command to simulate a shell environment. It worked! Below are the delegates.xml and configure.xml contents as run from proc_open on imagemagick's convert. It'd be really nice if i can get aound using a shell script but running IM commands directly through proc_open.

Delegates:

Code: Select all

Path: /usr/local/etc/ImageMagick/delegates.xml

Delegate Command
-------------------------------------------------------------------------------
blender => "blender" -b "%i" -F PNG -o "%o""\n"convert" -concatenate "%o*.png" "%o"
cdr => "uniconvertor" "%i" "%o.svg"; mv "%o.svg" "%o"
cgm => "ralcgm" -d ps -oC < "%i" > "%o" 2> "%Z"
dng:decode => "ufraw-batch" --silent --create-id=also --out-type=png --out-depth=16 "--output=%u.png" "%i"
dot => "dot" -Tsvg "%i" -o "%o"
dvi => "dvips" -q -o "%o" "%i"
eps<=>pdf "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 "-sDEVICE=pdfwrite" "-sOutputFile=%o" "-f%i"
eps<=>ps "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pswrite" "-sOutputFile=%o" "-f%i"
fig => "fig2dev" -L ps "%i" "%o"
hpg => "hp2xx" -q -m eps -f `basename "%o"` "%i"; mv -f `basename "%o"` "%o"
hpgl => "if [ -e hp2xx -o -e /usr/bin/hp2xx ]; then hp2xx -q -m eps -f `basename "%o"` "%i"; mv -f `basename "%o"` "%o"; else echo "You need to install hp2xx to use HPGL files with ImageMagick."; exit 1; fi"
htm => "html2ps" -U -o "%o" "%i"
html => "html2ps" -U -o "%o" "%i"
https => "curl" -s -k -o "%o" "https:%M"
ilbm => "ilbmtoppm" "%i" > "%o"
man => "groff" -man -Tps "%i" > "%o"
miff<= show "/usr/local/bin/display" -delay 0 -window-group %[group] -title "%l " "ephemeral:%i"
mpeg:decode => "ffmpeg" -v -1 -i "%i" -vframes %S -vcodec pam -an -f rawvideo -y "%u.pam" 2> "%Z"
pdf<=>eps "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=epswrite" "-sOutputFile=%o" "-f%i"
pdf<=>ps "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pswrite" "-sOutputFile=%o" "-f%i"
plt => "echo" "set size 1.25,0.62; set terminal postscript portrait color solid; set output \'%o\'; load \'%i\'" > "%u";"gnuplot" "%u"
pnm<= ilbm "ppmtoilbm" -24if "%i" > "%o"
pov => "povray" "+i%i" -D0 "+o%o" +fn%q +w%w +h%h +a -q9 "-kfi%s" "-kff%n";"convert" -concatenate "%o*.png" "%o"
ps<=>eps "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=epswrite" "-sOutputFile=%o" "-f%i"
ps<=>pdf "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pdfwrite" "-sOutputFile=%o" "-f%i"
ps<= print "lpr "%i"
rgba<= rle "rawtorle" -o "%o" -v "%i"
scan => "scanimage" -d "%i" > "%o"
scanx => "scanimage" > "%o"
shtml => "html2ps" -U -o "%o" "%i"
sid => "mrsidgeodecode" -if sid -i "%i" -of tif -o "%o" > "%u"
svg => "rsvg-convert" -o "%o" "%i"
tiff<= launch "gimp" "%i"
txt<=>ps "enscript" -o "%o" "%i"
wmf => "wmf2eps" -o "%o" "%i"
Configure:

Code: Select all

Path: /usr/local/lib/ImageMagick-6.7.9/config/configure.xml

Name Value
-------------------------------------------------------------------------------
CC gcc -std=gnu99 -std=gnu99
CFLAGS -g -O2 -Wall -fPIC
CODER_PATH /usr/local/lib/ImageMagick-6.7.9/modules-Q16/coders
CONFIGURE ./configure 'LDFLAGS=-L/usr/lib64 -R/usr/lib64' 'CFLAGS=-g -O2 -Wall -fPIC' 'CXXFLAGS=-g -O2 -fPIC' '-without-x' '-without-threads'
CONFIGURE_PATH /usr/local/etc/ImageMagick/
COPYRIGHT Copyright (C) 1999-2012 ImageMagick Studio LLC
CPPFLAGS -I/usr/local/include/ImageMagick
CXX g++
CXXFLAGS -g -O2 -fPIC
DEFS -DHAVE_CONFIG_H
DELEGATES bzlib djvu fontconfig freetype jpeg jng jp2 lcms pango png tiff xml zlib
DISTCHECK_CONFIG_FLAGS 'CFLAGS=-g -O2 -Wall -fPIC' 'LDFLAGS=-L/usr/lib64 -R/usr/lib64' --disable-deprecated --with-quantum-depth=16 --with-umem=no --with-autotrace=no --with-gslib=no --with-fontpath= --with-gvc=no --with-rsvg=no --with-wmf=no --with-perl=no
DOCUMENTATION_PATH /usr/local/share/doc/ImageMagick-6.7.9
EXEC-PREFIX /usr/local
EXECUTABLE_PATH /usr/local/bin
FEATURES
FILTER_PATH /usr/local/lib/ImageMagick-6.7.9/modules-Q16/filters
HOST x86_64-unknown-linux-gnu
INCLUDE_PATH /usr/local/include/ImageMagick
LDFLAGS -L/usr/local/lib -L/usr/lib64 -R/usr/lib64 -L/usr/lib
LIB_VERSION 0x679
LIB_VERSION_NUMBER 6,7,9,0
LIBRARY_PATH /usr/local/lib/ImageMagick-6.7.9
LIBS -lMagickCore -llcms -ltiff -lfreetype -ljasper -ljpeg -lpng12 -ldjvulibre -lfontconfig -lbz2 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lxml2 -lz -lm -lgomp -lltdl
NAME ImageMagick
PCFLAGS
PREFIX /usr/local
QuantumDepth 16
RELEASE_DATE 2012-08-17
SHARE_PATH /usr/local/share/ImageMagick-6.7.9
SVN_REVISION 8971
TARGET_CPU x86_64
TARGET_OS linux-gnu
TARGET_VENDOR unknown
VERSION 6.7.9
WEBSITE http://www.imagemagick.org

Path: [built-in]

Name Value
-------------------------------------------------------------------------------
NAME ImageMagick

Re: png32:- works, png:- doesn't

Posted: 2012-08-17T21:17:22-07:00
by CodeFan
In utter dismay I report the problem having vanished all of a sudden! That's the strangest issue i've ever had to deal with. i just replaced png32:- with png:- and now it's working like a charm. Just like that. I have a feeling the problem will be back though. I'll continue the thread when i start getting that error again.
Here's the latest output using the plain png:- output:
Image

Re: png32:- works, png:- doesn't

Posted: 2012-08-17T21:21:46-07:00
by fmw42
CodeFan wrote:In utter dismay I report the problem having vanished all of a sudden! That's the strangest issue i've ever had to deal with. i just replaced png32:- with png:- and now it's working like a charm. Just like that. I have a feeling the problem will be back though. I'll continue the thread when i start getting that error again.
Here's the latest output using the plain png:- output:
Image

Might you have accidentally type a long or short hyphen with png:-? That might account for it.

Re: png32:- works, png:- doesn't

Posted: 2012-08-18T01:54:26-07:00
by CodeFan
Might you have accidentally type a long or short hyphen with png:-? That might account for it.
My first thought was that my syntax is wrong. That's why i made the php output the command to the browser instead of the image. Then copy/pasted from the browser into bash and it all worked there but not in proc_open. It's all working now. I'm using Komodo and i'm not sure if i can add a long dash with the kbd into it. Thanks for your involvement in the problem though.