unable to convert to tif using stdout to BufferedImage

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
gjones99
Posts: 2
Joined: 2011-02-07T15:47:43-07:00
Authentication code: 8675308

unable to convert to tif using stdout to BufferedImage

Post by gjones99 »

I'm trying to convert a png to a tif file in memory (without writing the file to the file system) and am getting the "unable to write blob" error. Thinking that it has something to do with not deleting tmp files.

Windows 7 Enterprise
Version ImageMagick-6.6.7-Q16

You can duplicate the error message at the command line in image magick by trying to convert the .png file to a tif in stdout. (Probably not a great test, but if you try doing the same thing as a .jpg, it streams the output to the screen)

02/10/2011 02:58 PM 3,711 ScanCompressedThumbNailImage.png

C:\EVO\E360\E360Batch\src\test\resources\images>convert ScanCompressedFullPageImage.png "tif:-"
Magick: unable to write blob `-': Not enough space @ error/blob.c/ImageToFile/1662.


I'm using im4java and this is where I initially received the error message. Here is my java code: Note if I try writing the image to the file system by uncommenting the code below, the file is written to the os with no problems.

Code: Select all

     public  byte[] convertPngToTifImage(byte[] fullPagePNGImage) throws IOException, InterruptedException, IM4JavaException {
   	File output = new File("src/test/resources/images/ScanCompressedFullPageImage.png");

        IMOperation op = new IMOperation();
        op.addImage(); //place holder for input file
//        op.addImage(output.getAbsoluteFile().toString()); // used to verify that a file can be written to the file system.
        op.addImage("tif:-"); // output: stdout
        
        ConvertCmd convert = new ConvertCmd();
        Stream2BufferedImage s2b = new Stream2BufferedImage();
        convert.setOutputConsumer(s2b);

        // run command and extract BufferedImage from OutputConsumer
        convert.run(op, fullPagePNGImage );
        BufferedImage img = s2b.getImage(); 
   
        return img;

Anyone seen this behavior or have a work around?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: unable to convert to tif using stdout to BufferedImage

Post by magick »

This works for us:
  • convert logo: tif:- > logo.tif
    identify logo.tif
Does that work for you? We need to determine if the problem is specific to your image (ScanCompressedFullPageImage.png).
gjones99
Posts: 2
Joined: 2011-02-07T15:47:43-07:00
Authentication code: 8675308

Re: unable to convert to tif using stdout to BufferedImage

Post by gjones99 »

That should work for you, it also works for me, there is not a problem with that command and my image is fine. I can convert a png to a physical tif file all day long. However, I am trying to avoid writing actual files to the file system when running the convert command.

Here is the background:
The png and tif images we are dealing with are stored in a sql database. We are reading multi-page tif files in, breaking them out into full page png images and thumbnails and display them dynamically on web pages on the fly. The user can select one or more png images and then we convert them to a multi-page tif image that is then saved directly in the database. The image is not written to the file system at that time.

So when working with these images, I'm trying to avoid writing files to the file system, as in your example. I'm using a third party java api (im4java) to call the image magick commands. That was the code that was in the previous post, but don't let that distract you. The error is coming from image magick.


Run this command and you will see the error!
convert yourImage.png "tif:-"


This command appears to be outputting the jpg to the screen .
convert ScanCompressedFullPageImage.png "jpg:-"

I know I shouldn't be running the above commands under normal circumstances, however, it is the easiest way to duplicate the error.
veeramarni
Posts: 1
Joined: 2013-06-02T11:37:14-07:00
Authentication code: 6789

Re: unable to convert to tif using stdout to BufferedImage

Post by veeramarni »

Was this fixed? I am having the same issue.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: unable to convert to tif using stdout to BufferedImage

Post by fmw42 »

I do not think you can do this without stuff going to the terminal

convert rose: tif:-

It is sending to std out but no place to get received but the terminal

but you can do pipe to std in and then process it further.

convert rose: tif:- | convert - rose.tif

or

convert rose: tif:- > /dev/null
Post Reply