Convert raw image: size problem
Convert raw image: size problem
Hello there,
I am a new guy to use Linux system and this IM.
I have a question about command "convert -size" for converting raw image.
Here it is:
So far as I know, convert -size value needs specific numbers for the size, and it works of course.
Now I would like to convert many raw images with different sizes in a loop, so i did like this:
uUe an array size(2) for the width and height, so the command is convert ... -size $size[1]x$size[2] ...
But it gave me an error message that "Must specify image size", I checked but still dont know how to do.
Can anyone help me ?
Thanks in advance!
PS: I worked for version 5.*, but failed for 6.*
I am a new guy to use Linux system and this IM.
I have a question about command "convert -size" for converting raw image.
Here it is:
So far as I know, convert -size value needs specific numbers for the size, and it works of course.
Now I would like to convert many raw images with different sizes in a loop, so i did like this:
uUe an array size(2) for the width and height, so the command is convert ... -size $size[1]x$size[2] ...
But it gave me an error message that "Must specify image size", I checked but still dont know how to do.
Can anyone help me ?
Thanks in advance!
PS: I worked for version 5.*, but failed for 6.*
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert raw image: size problem
arrays in (bash) unix start with index 0
and are referenced as
-size ${size[0]}x${size[1]}
the braces are important. For more information on arrays in unix, search google for "bash array"
Strongly urge you to upgrade to the latest IM 6.6.0-5. IM 5 is very old. Many improvements have been made since then.
Also see
http://www.imagemagick.org/Usage/
and in particular http://www.imagemagick.org/Usage/basics/#why
and are referenced as
-size ${size[0]}x${size[1]}
the braces are important. For more information on arrays in unix, search google for "bash array"
Strongly urge you to upgrade to the latest IM 6.6.0-5. IM 5 is very old. Many improvements have been made since then.
Also see
http://www.imagemagick.org/Usage/
and in particular http://www.imagemagick.org/Usage/basics/#why
Re: Convert raw image: size problem
Thank you very much for your quick reply, fmw42.
I use Cshell and when using echo ''${size[1]}x${size[2]} '', it can give right answer.
So maybe it is not that problem.
And I changed ''$size[1]x$size[2]'' to ''${size[1]}x${size[2]} '', still have the same problem.
I use Cshell and when using echo ''${size[1]}x${size[2]} '', it can give right answer.
So maybe it is not that problem.
And I changed ''$size[1]x$size[2]'' to ''${size[1]}x${size[2]} '', still have the same problem.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert raw image: size problem
What is your exact command?
Did you specify RGB:inputimage.raw i.e. the prefix RGB:
Where are you getting the raw image?
Do you have the correct delegate library installed for reading raw images. In Windows, it is DCRAW, but I am not sure I know what it is for Unix.
Did you specify RGB:inputimage.raw i.e. the prefix RGB:
Where are you getting the raw image?
Do you have the correct delegate library installed for reading raw images. In Windows, it is DCRAW, but I am not sure I know what it is for Unix.
Last edited by fmw42 on 2010-03-14T00:04:12-07:00, edited 1 time in total.
Re: Convert raw image: size problem
Ok, here is my exact command:
convert -depth 8 -normalize -quality 100 -colorspace gray -geometry 15% -size $size2[1]x$size2[2] gray:$cwd/$image1 $outimage.png
Just now I read the website you gave to me and found that maybe the problem of the order of the parameters.
The raw images are the satellite data.
convert -depth 8 -normalize -quality 100 -colorspace gray -geometry 15% -size $size2[1]x$size2[2] gray:$cwd/$image1 $outimage.png
Just now I read the website you gave to me and found that maybe the problem of the order of the parameters.
The raw images are the satellite data.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert raw image: size problem
I am not sure -geometry 15% is valid in this context. It is used when doing composites. I think you want -resize.
for IM 6 try
convert -colorspace gray -size $size2[1]x$size2[2] gray:$cwd/$image1 -resize 15% -normalize -depth 8 -quality 100 $outimage.png
for IM 6 try
convert -colorspace gray -size $size2[1]x$size2[2] gray:$cwd/$image1 -resize 15% -normalize -depth 8 -quality 100 $outimage.png
Re: Convert raw image: size problem
Sorry, still not working.
The value of "${size[1]}x${size[2]}" can not be passed to the convert command.
This is the problem.
The value of "${size[1]}x${size[2]}" can not be passed to the convert command.
This is the problem.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert raw image: size problem
try using simple variables instead of array elements. put width in one variable and height in another
in bash
width=500
height=500
convert -size ${width}x${height} ....
in bash shell, I know this works as well as using arrays such as ${size[0]}x${size[1]} where the index of the array starts at 0. I don't use the C shell, so cannot say how to use arrays there with IM.
Have you verified that you are getting the right values in your arrays. Try echo the values back to the shell to see they are correct.
Also just try hard coding the sizes
convert -size 500x500 ...
and see if that works correctly.
in bash
width=500
height=500
convert -size ${width}x${height} ....
in bash shell, I know this works as well as using arrays such as ${size[0]}x${size[1]} where the index of the array starts at 0. I don't use the C shell, so cannot say how to use arrays there with IM.
Have you verified that you are getting the right values in your arrays. Try echo the values back to the shell to see they are correct.
Also just try hard coding the sizes
convert -size 500x500 ...
and see if that works correctly.
Re: Convert raw image: size problem
Hi, fmw42,
Sorry for not posting the problem completely.
I tried the "-size 300x400" before and it works, but the "-size ${size[1]}${size[2]}" does not work for IM v6 but works for IM v5.
because i dont know much about unix and cshell, i can not find out the reason...
Sorry for not posting the problem completely.
I tried the "-size 300x400" before and it works, but the "-size ${size[1]}${size[2]}" does not work for IM v6 but works for IM v5.
because i dont know much about unix and cshell, i can not find out the reason...
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert raw image: size problem
-size ${size[1]}${size[2]}
did you mean
-size ${size[1]}x${size[2]}
or have you forgotten to include the x?
Can you try with normal variables rather than an array? Why do you need the array?
Can you switch to the bash shell?
Did you echo your array elements to verify that they contain the right values?
did you mean
-size ${size[1]}x${size[2]}
or have you forgotten to include the x?
Can you try with normal variables rather than an array? Why do you need the array?
Can you switch to the bash shell?
Did you echo your array elements to verify that they contain the right values?
Re: Convert raw image: size problem
Sorry, my fault, it is -size ${size[1]}x${size[2]}.
I echoed the array elements and they were right.
because I need to process many raw images, and their sizes are different so I can not just give two constants for the size.
I am not sure if I can shift to b shell, but i wonder if it is the problem of C shell, because I can get correct results from IM v5 with the same program under C shell.
I echoed the array elements and they were right.
because I need to process many raw images, and their sizes are different so I can not just give two constants for the size.
I am not sure if I can shift to b shell, but i wonder if it is the problem of C shell, because I can get correct results from IM v5 with the same program under C shell.
Last edited by aboys on 2010-03-14T00:39:47-07:00, edited 1 time in total.
Re: Convert raw image: size problem
Sorry, my fault, it is -size ${size[1]}x${size[2]}.
I echoed the array elements and they were right.
because I need to process many raw images, and their sizes are different so I can not just give two constants for the size.
I am not sure if I can shift to b shell, but i wonder if it is the problem of C shell, because I can get correct results from IM v5 with the same program under C shell.
I echoed the array elements and they were right.
because I need to process many raw images, and their sizes are different so I can not just give two constants for the size.
I am not sure if I can shift to b shell, but i wonder if it is the problem of C shell, because I can get correct results from IM v5 with the same program under C shell.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert raw image: size problem
but can you not change the two variables for each image, just like you change the elements of the array?
or set two variable to be set equal to the two array elements and then reference the variables in the -size arguments
width=$size[1]
height=$size[2]
convert -size ${width}x${height} ....
does it work with
-size $size[1]x$size[2]
or set two variable to be set equal to the two array elements and then reference the variables in the -size arguments
width=$size[1]
height=$size[2]
convert -size ${width}x${height} ....
does it work with
-size $size[1]x$size[2]
Re: Convert raw image: size problem
Ok, I can try that.
-size $size[1]x$size[2] also works.
Well, thank you very much, fmw42, for your helpful, kind and quick reply.
I am not sure if it works after changing the settings, but i should not waste your time any more.
Maybe i ignored some points which i never know before, so i would like to check it in details again.
Hope I can find something.
Thank you very much again for your help.
-size $size[1]x$size[2] also works.
Well, thank you very much, fmw42, for your helpful, kind and quick reply.
I am not sure if it works after changing the settings, but i should not waste your time any more.
Maybe i ignored some points which i never know before, so i would like to check it in details again.
Hope I can find something.
Thank you very much again for your help.

- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert raw image: size problem
OK. I am out of ideas for the moment and time for bed anyway. So I will check again tomorrow and let you know if I have any further thoughts or if you find other issues, let me know.