iOS ConvertImageCommand UnableToOpenBlob

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
amygooch
Posts: 7
Joined: 2012-02-21T12:02:41-07:00
Authentication code: 8675308

iOS ConvertImageCommand UnableToOpenBlob

Post by amygooch »

Hi,
I'm trying to use ConvertImageCommand and port over a script like:

Code: Select all

convert rose: -background black -gravity south -splice 0x8 \
     \( +clone -sparse-color barycentric '0,0 black 69,0 white' \) \
     \( +clone -function arcsin 0.5 \) \
     \( -clone 1 -level 25%,75% \
     -function polynomial -4,4,0 -gamma 2 \
     +level 50%,0 \) \
     -delete 1 -swap 0,1  miff:- |\
     composite - -virtual-pixel black  -displace 17x7  rose_cylinder.png
But I am getting a lot of errors, which I originally thought was the imagemagick installation, but based on 5 days of looking all over the web and this server for answers, it seems like it may be the way I'm trying to break up the script into strings.

Can anyone help me with reference to how to split up strings for the ConvertImageCommand?

Code and Errors below,

Amy


The code:

Code: Select all

       LOG(@"In clyindericalWarp\n");
    char *args[] = {"convert", "rose:", "-background", "black", "-gravity", "south", "-splice", "0x8",
    "\\(", "+clone", "-sparse-color", "barycentric", "'0,0 black 69,0 white", "\\)" , 
        "\\(",  "+clone", "-function", "arcsin", "0.5", "\\) ",
    "\\(", "-clone", "1", "-level", "25%,75%", 
      "-function", "polynomial", "-4,4,0", "-gamma", "2", 
      "+level", "50%,0","\\)", 
    "-delete", "1", "-swap", "0,1",  "miff:-", 
        "|" ,        "composite", "-" ,"-virtual-pixel", "black",  "-displace" ,"17x7" , "rose_cylinder.png",NULL};
  
     
     MagickCoreGenesis("",MagickFalse);
     
    
     int args_count;
    for(args_count = 0; args[args_count] != (char *)NULL; args_count++);
    
       
     ImageInfo *image_info = AcquireImageInfo();
     ExceptionInfo *exception = AcquireExceptionInfo();
     
     MagickBooleanType status =
     ConvertImageCommand(image_info, args_count, args, NULL, exception);
     
     if (exception->severity != UndefinedException)
     {
     status=MagickTrue;
     CatchException(exception);
     }
     
     // This should not be needed as error is reported as an exception
     if (status == MagickFalse)
     fprintf(stderr, "Error in call\n");
     
     image_info=DestroyImageInfo(image_info);
     exception=DestroyExceptionInfo(exception);
      
     MagickCoreTerminus();

The errors:


: UnableToOpenConfigureFile `colors.xml' @ warning/configure.c/GetConfigureOptions/591.
: UnableToOpenBlob `\(': No such file or directory @ error/blob.c/OpenBlob/2614.
: UnableToOpenConfigureFile `delegates.xml' @ warning/configure.c/GetConfigureOptions/591.
: NoDecodeDelegateForThisImageFormat `\(' @ error/constitute.c/ReadImage/532.
: InvalidArgument `sparse-color': Invalid number of Arguments @ error/mogrify.c/SparseColorOption/517.
: UnableToOpenBlob `\)': No such file or directory @ error/blob.c/OpenBlob/2614.
: NoDecodeDelegateForThisImageFormat `\)' @ error/constitute.c/ReadImage/532.
: UnableToOpenBlob `\(': No such file or directory @ error/blob.c/OpenBlob/2614.
: NoDecodeDelegateForThisImageFormat `\(' @ error/constitute.c/ReadImage/532.
: UnableToOpenBlob `\) ': No such file or directory @ error/blob.c/OpenBlob/2614.
: NoDecodeDelegateForThisImageFormat `\) ' @ error/constitute.c/ReadImage/532.
: UnableToOpenBlob `\(': No such file or directory @ error/blob.c/OpenBlob/2614.
: NoDecodeDelegateForThisImageFormat `\(' @ error/constitute.c/ReadImage/532.
: UnableToOpenBlob `\)': No such file or directory @ error/blob.c/OpenBlob/2614.
: NoDecodeDelegateForThisImageFormat `\)' @ error/constitute.c/ReadImage/532.
: ImproperImageHeader `/Users/gooch/Library/Application Support/iPhone Simulator/5.0/Applications/B7232AA7-7B2E-4CA7-9ACF-B6C403026113/tmp/magick-Weowj5zy' @ error/miff.c/ReadMIFFImage/507.
: NoDecodeDelegateForThisImageFormat `/Users/gooch/Library/Application Support/iPhone Simulator/5.0/Applications/B7232AA7-7B2E-4CA7-9ACF-B6C403026113/tmp/magick-d0sWhqAQ' @ error/constitute.c/ReadImage/532.
: UnableToOpenBlob `composite': No such file or directory @ error/blob.c/OpenBlob/2614.
: NoDecodeDelegateForThisImageFormat `composite' @ error/constitute.c/ReadImage/532.
: NoDecodeDelegateForThisImageFormat `/Users/gooch/Library/Application Support/iPhone Simulator/5.0/Applications/B7232AA7-7B2E-4CA7-9ACF-B6C403026113/tmp/magick-o8grgMnb' @ error/constitute.c/ReadImage/532.
: UnrecognizedOption `-displace' @ error/convert.c/ConvertImageCommand/1312.
amygooch
Posts: 7
Joined: 2012-02-21T12:02:41-07:00
Authentication code: 8675308

Re: iOS ConvertImageCommand UnableToOpenBlob

Post by amygooch »

I've gotten closer by fixing the parenthesis and single quotes... removing \ and removing '

(Note I've had to find these by hunting and pecking... I could still not find any documentation on how to convert from script to code arguments.. hopefully this will save others time in the future)

currently the code and failures are:

Code: Select all

     char *args[] = {"convert", "rose:", "-background", "black", "-gravity", "south", "-splice", "0x8",
        "(", "+clone", "-sparse-color", "barycentric", "0,0 black 69,0 white", ")" , 
        "(",  "+clone", "-function", "arcsin", "0.5", ")",
    "(", "-clone", "1", "-level", "25%,75%", 
      "-function", "polynomial", "-4,4,0", "-gamma", "2", 
      "+level", "50%,0",")", 
    "-delete", "1", "-swap", "0,1",  "miff:-", 
        "|" ,        "composite", "-" ,"-virtual-pixel", "black",  "-displace" ,"17x7" , "rose_cylinder.png",NULL};
now the error is:

: UnableToOpenConfigureFile `colors.xml' @ warning/configure.c/GetConfigureOptions/591.
: ImproperImageHeader `/Users/gooch/Library/Application Support/iPhone Simulator/5.0/Applications/B7232AA7-7B2E-4CA7-9ACF-B6C403026113/tmp/magick-qbsH4HNL' @ error/miff.c/ReadMIFFImage/507.
: UnableToOpenConfigureFile `delegates.xml' @ warning/configure.c/GetConfigureOptions/591.
: NoDecodeDelegateForThisImageFormat `/Users/gooch/Library/Application Support/iPhone Simulator/5.0/Applications/B7232AA7-7B2E-4CA7-9ACF-B6C403026113/tmp/magick-r8wJbnwY' @ error/constitute.c/ReadImage/532.
: UnableToOpenBlob `composite': No such file or directory @ error/blob.c/OpenBlob/2614.
: NoDecodeDelegateForThisImageFormat `composite' @ error/constitute.c/ReadImage/532.
: NoDecodeDelegateForThisImageFormat `/Users/gooch/Library/Application Support/iPhone Simulator/5.0/Applications/B7232AA7-7B2E-4CA7-9ACF-B6C403026113/tmp/magick-Dgv2UHbU' @ error/constitute.c/ReadImage/532.
: UnrecognizedOption `-displace' @ error/convert.c/ConvertImageCommand/1312.
amygooch
Posts: 7
Joined: 2012-02-21T12:02:41-07:00
Authentication code: 8675308

Re: iOS ConvertImageCommand UnableToOpenBlob

Post by amygooch »

Resolved.

Another problem is that the composite portion of the script has to be done via CompositeImageCommand. I will post the solution when it finally works.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: iOS ConvertImageCommand UnableToOpenBlob

Post by anthony »

The use of '\' and quotes (other than internal quotes for -draw strings) are for shell parsing.

You are essentially doing that shell parsing yourself and as such do not need them.

'\(' is essentially a unrecognised option, and does not even look like a option (does not start with '+' or '-') and as such IM decieded to try and interpret the argument as being a image filename to read.

The 'blob' function is used to open files, streams, and in-memory strings, as possible sources of image data. And it is here that it 'bombs out'. Thus the cause of your unusual and un-informative 'error'.

The new errors you are getting is because IM is doe some reason having trouble locating its configuration files.
Perhaps it is missing some environment settings required by the specific installation on your machine.

Can you actually run a command line IM command like

Code: Select all

convert -version
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: iOS ConvertImageCommand UnableToOpenBlob

Post by anthony »

Also not that as you are NOT using a shell, you can not use shell piping between commands. "|"

however "convert" can do image composition, so you can merge it into a single command...
See... IM Examples, Image Composition in IM
http://www.imagemagick.org/Usage/compose/#compose
Near the bottom of 'Definition of Terms' which describes how to pass 'special compose arguments' in convert.

Code: Select all

...
  "-delete", "1", "-swap", "0,1", 
  "-virtual-pixel", "black",  "-compose", "displace",  "-define", "compose:args=17x7",  "-composite",
  "rose_cylinder.png",  NULL };

Note for debugging you can insert operations such as
"+write", "/tmp/image1.png",

To see the intermediate images.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
amygooch
Posts: 7
Joined: 2012-02-21T12:02:41-07:00
Authentication code: 8675308

Re: iOS ConvertImageCommand UnableToOpenBlob

Post by amygooch »

Thank you for the reply.

However, I can not get the following to work.. it appears not to be doing the "-delete 1 -swap 0,1" portion of the script (I was testing the script edits before getting it to work in iOS)

Code: Select all

     convert rose: -background black -gravity south -splice 0x8 \
     \( +clone -sparse-color barycentric '0,0 black 69,0 white' \) \
     \( +clone -function arcsin 0.5 \) \
     \( -clone 1 -level 25%,75% \
     -function polynomial -4,4,0 -gamma 2 \
     +level 50%,0 \) \
     -delete 1 -swap 0,1  \
  -virtual-pixel black   -compose displace -define compose:args=17x7  -composite \
   rose_cylinder_warp.png
Last edited by amygooch on 2012-02-22T16:12:57-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: iOS ConvertImageCommand UnableToOpenBlob

Post by fmw42 »

Try removing all the indents and pasting into your terminal. This works fine for me on IM 6.7.5.6 Q16 Mac OSX Snow Leopard.


convert rose: -background black -gravity south -splice 0x8 \
\( +clone -sparse-color barycentric '0,0 black 69,0 white' \) \
\( +clone -function arcsin 0.5 \) \
\( -clone 1 -level 25%,75% \
-function polynomial -4,4,0 -gamma 2 \
+level 50%,0 \) \
-delete 1 -swap 0,1 miff:- |\
composite - -virtual-pixel black -displace 17x7 rose_cylinder.png


What version of iM and platform are you using?
amygooch
Posts: 7
Joined: 2012-02-21T12:02:41-07:00
Authentication code: 8675308

Re: iOS ConvertImageCommand UnableToOpenBlob

Post by amygooch »

Ugh! Thank you for your patience with me.. I thought I had it working, but it is not
( @Fred, I'm trying to run that one that doesn't pipe it into compose but uses the comment Anthony posted).

Code: Select all

convert rose: -background black -gravity south -splice 0x8\
\( +clone -sparse-color barycentric '0,0 black 69,0 white' \)\
\( +clone -function arcsin 0.5 \)\
\( -clone 1 -level 25%,75%\
-function polynomial -4,4,0 -gamma 2\
+level 50%,0 \)\
-delete 1 -swap 0,1\
-virtual-pixel black -compose displace -define compose:args=17x7 -composite rose_cylinder_warp.png
Any help is greatly appreciated, You guys Rock!
amygooch
Posts: 7
Joined: 2012-02-21T12:02:41-07:00
Authentication code: 8675308

Re: iOS ConvertImageCommand UnableToOpenBlob

Post by amygooch »

convert -version
Version: ImageMagick 6.7.5-3 2012-02-18 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenCL
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: iOS ConvertImageCommand UnableToOpenBlob

Post by fmw42 »

First you must have spaces between the text and the line continuation \

So it would properly be:

convert rose: -background black -gravity south -splice 0x8 \
\( +clone -sparse-color barycentric '0,0 black 69,0 white' \) \
\( +clone -function arcsin 0.5 \) \
\( -clone 1 -level 25%,75% \
-function polynomial -4,4,0 -gamma 2 \
+level 50%,0 \) \
-delete 1 -swap 0,1 \
-virtual-pixel black -compose displace -define compose:args=17x7 -composite rose_cylinder_warp.png

However when switching from composite to convert -composite, the input images need to be swapped. see http://www.imagemagick.org/Usage/compose/#compose

So it should then be (remove the -swap 0,1), which then produces the proper image for me as follows:


convert rose: -background black -gravity south -splice 0x8 \
\( +clone -sparse-color barycentric '0,0 black 69,0 white' \) \
\( +clone -function arcsin 0.5 \) \
\( -clone 1 -level 25%,75% \
-function polynomial -4,4,0 -gamma 2 \
+level 50%,0 \) \
-delete 1 \
-virtual-pixel black -compose displace -define compose:args=17x7 -composite rose_cylinder_warp.png


NOTE: if you are on Linux or Mac OSX or Windows with Cygwin, you can use my cylinderize script at the link below.
amygooch
Posts: 7
Joined: 2012-02-21T12:02:41-07:00
Authentication code: 8675308

Re: iOS ConvertImageCommand UnableToOpenBlob

Post by amygooch »

yahoo! I swear I tried that ... thank you so much for your time.

Amy
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: iOS ConvertImageCommand UnableToOpenBlob

Post by fmw42 »

amygooch wrote:yahoo! I swear I tried that ... thank you so much for your time.

Amy

You may have tried the swap issue, but missed the space before the line ending \. That is a common mistake that I make from time to time. And is one of the first things that I check.
Post Reply