Page 1 of 1
Convert always returning exit code '1'
Posted: 2017-03-29T18:18:10-07:00
by i73
Hey, I am lost as to why my command is constantly returning '1'/"Failed" exit code even though it converts the texture.
Code: Select all
string.Format("convert \"{0}\" -depth 8 -resize {1}x{1} -sharpen 0x1.5 \"{2}.png\"", file, size, (file.Split('.')[0] + "_" + size)))
it's basically "convert 'image.png' -resize 32 -sharpen 0x1.5 ' image_32.png"
Looking at '-Debug all' I see no Exceptions or Errors in command line, is IM convert returning 1 a bug? Or am I overlooking something?
Re: Convert always returning exit code '1'
Posted: 2017-03-29T19:21:29-07:00
by fmw42
"convert 'image.png' -resize 32 -sharpen 0x1.5 ' image_32.png"
You seem to have a missing single quote at the end. It should be
Code: Select all
"convert 'image.png' -resize 32 -sharpen 0x1.5 ' image_32.png'"
Check your variables also to see they are evaluating as you expect.
If I do:
Code: Select all
convert logo: -resize 32 -sharpen 0x1.5 result.png
echo $?
0
So a return code of 0 is success. Thus a return code of 1 is failure/error.
Re: Convert always returning exit code '1'
Posted: 2017-03-30T05:08:27-07:00
by snibgo
How do you know convert is returning 1? The code shown merely sets a string. The command isn't actually executed.
If it does return 1, you should printf the value of string. That might provide a clue.
Please say what version IM you are using.
Re: Convert always returning exit code '1'
Posted: 2017-03-30T10:07:20-07:00
by i73
fmw42 wrote: ↑2017-03-29T19:21:29-07:00
"convert 'image.png' -resize 32 -sharpen 0x1.5 ' image_32.png"
You seem to have a missing single quote at the end. It should be
Code: Select all
"convert 'image.png' -resize 32 -sharpen 0x1.5 ' image_32.png'"
Check your variables also to see they are evaluating as you expect.
If I do:
Code: Select all
convert logo: -resize 32 -sharpen 0x1.5 result.png
echo $?
0
So a return code of 0 is success. Thus a return code of 1 is failure/error.
Sorry my mistake, the
"convert 'image.png' -resize 32 -sharpen 0x1.5 ' image_32.png"
was just me writing out what I am trying to do, I'm not actually using that. The code I am using is in the <CODE> brace above it.
Re: Convert always returning exit code '1'
Posted: 2017-03-30T10:10:22-07:00
by i73
snibgo wrote: ↑2017-03-30T05:08:27-07:00
How do you know convert is returning 1? The code shown merely sets a string. The command isn't actually executed.
If it does return 1, you should printf the value of string. That might provide a clue.
Please say what version IM you are using.
I know it's returning a 1 because I have a listener waiting for any exceptions, I don't understand how it converts the image but returns a 1.
I'm using the IM 6.8 library: ImageMagick-6.8.6-9-Q16-x86-dll
Re: Convert always returning exit code '1'
Posted: 2017-03-30T10:40:24-07:00
by snibgo
I've never known convert to return 1 when it shouldn't. So perhaps your listener code may have a bug.
I suppose you have printed the value of the string when it returns 1. Then you can run that exact command from the command line, and see what it returns.
Re: Convert always returning exit code '1'
Posted: 2017-03-30T10:53:37-07:00
by fmw42
Perhaps the return 1 is not coming from Imagemagick, but from somewhere else in your code.
If you run the same command with variables resolve to their actual value from the command line, does that return 1 or 0?
Re: Convert always returning exit code '1'
Posted: 2017-03-30T12:52:19-07:00
by i73
snibgo wrote: ↑2017-03-30T10:40:24-07:00
I've never known convert to return 1 when it shouldn't. So perhaps your listener code may have a bug.
I suppose you have printed the value of the string when it returns 1. Then you can run that exact command from the command line, and see what it returns.
Okay so now we're getting somewhere, yes I now tossed in the exception and I am seeing errors...
This is my exception:
Failed to run with : 'convert "C:\Users\my user\a.png" -depth 8 -resize 128 -sharpen 0x1.5 "C:\Users\my user\a_128.png"'
When I input that into command:
Code: Select all
convert.exe: unable to open image `C:/Users/my user/Downloads/a.png': No such file or directory @ error/blob.c/OpenBlob/2643.
convert.exe: unable to open file `C:/Users/my user/Downloads/a.png' @ error/png.c/ReadPNGImage/3994.
convert.exe: no images defined `C:/Users/my user/Downloads/a_128.png' @ error/convert.c/ConvertImageCommand/3108.
I don't know how it can both convert and open images while being unable to open all the images...
I already did try switching up my escape characters with forward and backwards slashes, mixed my quotations with single and double, any advice would help me out.
fmw42 wrote: ↑2017-03-30T10:53:37-07:00
Perhaps the return 1 is not coming from Imagemagick, but from somewhere else in your code.
If you run the same command with variables resolve to their actual value from the command line, does that return 1 or 0?
Yes I tried this already, from what I am putting into my .net code but now I am trying to call the exact line that I am outputting above ^.
Re: Convert always returning exit code '1'
Posted: 2017-03-30T12:57:10-07:00
by snibgo
Those error messages didn't come from that command. The directory names are different.
Re: Convert always returning exit code '1'
Posted: 2017-03-30T13:00:15-07:00
by fmw42
Your error message says it is unable to open image:
C:/Users/my user/Downloads/a.png
but in Windows, you should be using \ and not /.
Where is it getting the /? Do IM error messages replace the \ with /? Sorry I am not a Windows user. So just checking to be sure you typed the correct syntax.
Re: Convert always returning exit code '1'
Posted: 2017-03-30T13:02:30-07:00
by fmw42
Is convert.exe the IM convert or the Windows convert?
Re: Convert always returning exit code '1'
Posted: 2017-03-30T13:08:17-07:00
by i73
snibgo wrote: ↑2017-03-30T12:57:10-07:00
Those error messages didn't come from that command. The directory names are different.
Yes sorry my mistake, I am typing these out since my outputs are on a Window, other than the directories it's the exact same code (tried with both forward slashes and backslashes too).
fmw42 wrote: ↑2017-03-30T13:00:15-07:00
Your error message says it is unable to open image:
C:/Users/my user/Downloads/a.png
but in Windows, you should be using \ and not /.
Where is it getting the /? Do IM error messages replace the \ with /? Sorry I am not a Windows user. So just checking to be sure you typed the correct syntax.
No worries, I also tried in my c# to use both \ and / exact same issue with both of them.
Code: Select all
string command = string.Format("convert \"{0}\" -depth 8 -resize {1}x{1} -sharpen 0x1.5 \"{2}.png\"", file.Replace('\\', '/'), size, (file.Split('.')[0] + "_" + size).Replace('\\', '/'));
Do you guys know why I would get a failed to find image BUT still be able to convert?
Just want to thank you both for helping me out!
Re: Convert always returning exit code '1'
Posted: 2017-03-30T13:11:23-07:00
by i73
fmw42 wrote: ↑2017-03-30T13:02:30-07:00
Is convert.exe the IM convert or the Windows convert?
FFS! Yeah, we're using convert.exe... I over looked that Just had to remove "convert"... Thank you guys so much for your time!!!!!
SOLVED
(I'm dumb)