reading PNG reports always corrupt image

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
lunetics

reading PNG reports always corrupt image

Post by lunetics »

Hello,

System : FreeBSD 7.2
libpng 1.4.1
ImageMagick 6.6.1.10
pecl-imagick-3.0.0.r1

i encountered the following problem:

When running an identify on a PNG, everthing is fine:

identify -verbose png1.png

Code: Select all

Image: png1.png
  Format: PNG (Portable Network Graphics)
  Class: DirectClass
  Geometry: 800x415+0+0
  Resolution: 72x72
  Print size: 11.1111x5.76389
  Units: Undefined
  Type: TrueColorMatte
  Endianess: Undefined
  Colorspace: RGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
    alpha: 8-bit
  Channel statistics:
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 131.35 (0.5151)
      standard deviation: 94.7398 (0.371529)
      kurtosis: -1.53947
      skewness: -0.338458
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 157.659 (0.618269)
      standard deviation: 96.2496 (0.377449)
      kurtosis: -0.978799
      skewness: -0.858173
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 181.879 (0.713251)
      standard deviation: 106.26 (0.416704)
      kurtosis: -0.730232
      skewness: -1.09856
    Alpha:
      min: 0 (0)
      max: 255 (1)
      mean: 134.992 (0.529379)
      standard deviation: 126.927 (0.497752)
      kurtosis: -1.98184
      skewness: 0.118265
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 147.724 (0.57931)
      standard deviation: 109.479 (0.429329)
      kurtosis: -1.60508
      skewness: -0.468963
  Alpha: none   #00000000
  Rendering intent: Undefined
  Interlace: None
  Background color: white
  Border color: rgba(223,223,223,1)
  Matte color: grey74
  Transparent color: none
  Compose: Over
  Page geometry: 800x415+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Zip
  Orientation: Undefined
  Properties:
    date:create: 2010-06-15T15:26:58+02:00
    date:modify: 2005-06-25T05:22:48+02:00
    signature: 6e5885d81bda2ae27d3311e4816577d98961c922a7efb2d6004bb898dfa9135e
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 146KB
  Number pixels: 332K
  Pixels per second: 42.5M
  User time: 0.000u
  Elapsed time: 0:01.007
  Version: ImageMagick 6.6.1-10 2010-06-15 begin_of_the_skype_highlighting              0 2010-06-15      end_of_the_skype_highlighting begin_of_the_skype_highlighting              0 2010-06-15      end_of_the_skype_highlighting begin_of_the_skype_highlighting              0 2010-06-15      end_of_the_skype_highlighting Q16 http://www.imagemagick.org
When running in PHP, i get the following error:

php -r 'ini_set('display_errors', true);$im = new Imagick(); $im->readImage("png1.png"); var_dump($im->getImageFormat());'

Code: Select all

Fatal error: Uncaught exception 'ImagickException' with message 'corrupt image `/var/tmp/magick-pcDhdcxq' @ error/png.c/ReadPNGImage/3052' in Command line code:1
Stack trace:
#0 Command line code(1): Imagick->readimage('png1.png')
#1 {main}
  thrown in Command line code on line 1
Pecl-imagick is also loaded correctly:

Code: Select all

imagick
imagick module => enabled
imagick module version => 3.0.0RC1
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator
ImageMagick version => ImageMagick 6.6.1-10 2010-06-15 Q16 http://www.imagemagick.org
ImageMagick copyright => Copyright (C) 1999-2010 ImageMagick Studio LLC
ImageMagick release date => 2010-06-15
ImageMagick number of supported formats:  => 203
ImageMagick supported formats => 3FR, A, AI, ART, ARW, AVI, AVS, B, BGR, BGRA, BIE, BMP, BMP2, BMP3, BRF, BRG, C, CAL, CALS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CRW, CUR, CUT, DCM, DCR, DCX, DDS, DFONT, DNG, DOT, DPX, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, FAX, FITS, FRACTAL, FTS, G, G3, GBR, GIF, GIF87, GRADIENT, GRAY, GRB, GROUP4, HALD, HISTOGRAM, HRZ, HTM, HTML, ICB, ICO, ICON, INFO, INLINE, IPL, ISOBRL, J2C, JBG, JBIG, JNG, JP2, JPC, JPEG, JPG, JPX, K, K25, KDC, LABEL, M, M2V, M4V, MAP, MAT, MATTE, MIFF, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NULL, O, ORF, OTB, OTF, PAL, PALM, PAM, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PGX, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG24, PNG32, PNG8, PNM, PPM, PREVIEW, PS, PS2, PS3, PSB, PSD, PTIF, PWP, R, RADIAL-GRADIENT, RAF, RAS, RBG, RGB, RGBA, RGBO, RLA, RLE, SCR, SCT, SFW, SGI, SHTML, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UIL, UYVY, VDA, VICAR, VID, VIFF, VST, WBMP, WMV, WPG, X3F, XBM, XC, XCF, XPM, XPS, XV, Y, YCbCr, YCbCrA, YUV
imagick.locale_fix => 0 => 0
imagick.progress_monitor => 0 => 0


Also tried to reinstall libpng etc, no cure :/
Chris Riesen

Re: reading PNG reports always corrupt image

Post by Chris Riesen »

Just giving you a small heads up, in case you run into the same trouble. I just had the same thing, but not for all PNG's. I was loading a blob from a MS SQL database and it truncated the image's end. So without the full image present, ImageMagick was unable to read it correctly. Maybe check if there is something missing from your image?
bigmate

Re: reading PNG reports always corrupt image

Post by bigmate »

Bump.
I have the same problem in Freebsd 8, etc. It's so sad.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: reading PNG reports always corrupt image

Post by fmw42 »

When running an identify on a PNG, everthing is fine:

When running in PHP, i get the following error:

php -r 'ini_set('display_errors', true);$im = new Imagick(); $im->readImage("png1.png"); var_dump($im->getImageFormat());'
Sticking my nose in -- it looks like Imagemagick is fine, but the error is with IMagick. Imagemagick is not the creator of Imagick and does not support it as far as I know. I think you need to check your PHP/Imagick setup and/or post to the Imagick forum for help. Have you checked your environment with phpinfo.php?

Have you tried just doing it with PHP and the exec command to see if that even works?

What do you get from (change the path to convert to whatever is on your system):

<?php
exec("/usr/local/bin/convert -version",$out,$returnval);
print_r($out[0]);
?>

what about

<?php
exec("/usr/local/bin/identify -verbose /fullpathto/yourimage.png",$out,$returnval);
print_r($out[0]);
?>


What version of IMagick do you have installed? (I think the latest may be 3.01)
Post Reply