Error Converting PNG File
Posted: 2013-06-28T20:39:17-07:00
Hi,
I am using imagemagick in nodejs and I get this error when trying to resize and convert a PNG image to a JPG image using imagemagick-6.8.0-10 on my Mac v10.8.3:
Error: Command failed: convert: Expected 8192 bytes; found 7058 bytes `/var/tmp/magick-5575V2-7DKZLYZj1' @ warning/png.c/MagickPNGWarningHandler/1830.
convert: Read Exception `/var/tmp/magick-5575V2-7DKZLYZj1' @ error/png.c/MagickPNGErrorHandler/1804.
convert: corrupt image `/var/tmp/magick-5575V2-7DKZLYZj1' @ error/png.c/ReadPNGImage/4048.
convert: no images defined `/tmp/51cd11dbc2f44e2469b1619b_1372476626911.jpg' @ error/convert.c/ConvertImageCommand/3106.
Here is some sample code:
Any ideas on what could be wrong? Thanks!
I am using imagemagick in nodejs and I get this error when trying to resize and convert a PNG image to a JPG image using imagemagick-6.8.0-10 on my Mac v10.8.3:
Error: Command failed: convert: Expected 8192 bytes; found 7058 bytes `/var/tmp/magick-5575V2-7DKZLYZj1' @ warning/png.c/MagickPNGWarningHandler/1830.
convert: Read Exception `/var/tmp/magick-5575V2-7DKZLYZj1' @ error/png.c/MagickPNGErrorHandler/1804.
convert: corrupt image `/var/tmp/magick-5575V2-7DKZLYZj1' @ error/png.c/ReadPNGImage/4048.
convert: no images defined `/tmp/51cd11dbc2f44e2469b1619b_1372476626911.jpg' @ error/convert.c/ConvertImageCommand/3106.
Here is some sample code:
Code: Select all
// Download any PNG file
var source_image = "http://example.com/some_file.png";
var request = request_module.get(source_image, function(res) {
var imagedata = '';
res.setEncoding('binary');
res.on('data', function(chunk){
imagedata += chunk;
});
res.on('end', function() {
imagemagick.resize({
srcData: image_data,
dstPath: tmp_filename,
width: 1000,
quality: 0.8,
format: 'jpg'
},
});