Page 1 of 1
convert -crop
Posted: 2010-10-26T09:25:25-07:00
by ancou82
I use the next in my code but nothing is returned
Code: Select all
Runtime runtime = Runtime.getRuntime();
String cmd=="convert -crop 600x400+0x600 /capturas/Capture184.bmp /capturas/idof.bmp ";
Process process = runtime.exec("convert -crop 600x400+0x600 /capturas/Capture184.bmp /capturas/idof.bmp ");
// Process process = runtime.exec(cmd);
int exitVal = process.waitFor();
What's wrong here?
thanks in advanced
Re: convert -crop
Posted: 2010-10-26T09:37:17-07:00
by Bonzo
Code: Select all
String cmd=="convert -crop 600x400+0x600 /capturas/Capture184.bmp /capturas/idof.bmp ";
Should be:
Code: Select all
String cmd=="convert -crop 600x400+0+600 /capturas/Capture184.bmp /capturas/idof.bmp ";
600x400 is the crop size and the +0+600 is the offset - in your case the top left corner.
See:
http://www.imagemagick.org/script/comma ... s.php#crop
Re: convert -crop
Posted: 2010-10-26T09:54:10-07:00
by ancou82
Bonzo wrote:Code: Select all
String cmd=="convert -crop 600x400+0x600 /capturas/Capture184.bmp /capturas/idof.bmp ";
Should be:
Code: Select all
String cmd=="convert -crop 600x400+0+600 /capturas/Capture184.bmp /capturas/idof.bmp ";
600x400 is the crop size and the +0+600 is the offset - in your case the top left corner.
See:
http://www.imagemagick.org/script/comma ... s.php#crop
that is not the problem because when i execute the last sentence in the cmd creates a new image, but when i try to execute thorugh java code nothing is created. It just do nothing.
It's strange because i said before, the same sentence works con cmd and not working in java code
thanks
Re: convert -crop
Posted: 2010-10-26T10:03:54-07:00
by fmw42
your need to put the input image before -crop
convert input -crop WxH+X+Y +repage output
the repage removes the virtual canvas that may be causing problems as well.
see
http://www.imagemagick.org/Usage/crop/#crop_repage
http://www.imagemagick.org/Usage/basics/#cmdline
Re: convert -crop
Posted: 2010-10-26T10:25:03-07:00
by ancou82
Code: Select all
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("convert /capturas/Capture184.bmp -crop 600x400+0x600 +repage /capturas/idof.bmp");
It doesn't work when calling in java code, but in cmd it works too
What can be the problem?
Re: convert -crop
Posted: 2010-10-26T12:51:20-07:00
by fmw42
probably need the full path to convert.
typically
/usr/local/bin/convert
or
/usr/bin/convert
use
which convert to find where it is located and append the full path to convert.
Re: convert -crop
Posted: 2010-10-27T01:10:41-07:00
by ancou82
fmw42 wrote:probably need the full path to convert.
typically
/usr/local/bin/convert
or
/usr/bin/convert
use
which convert to find where it is located and append the full path to convert.
Now it works but I still have a problem.
The call is not working always. I have to execute a few times to get an image.
One more time...i don't understand why.
Thanks a lot!!
Re: convert -crop
Posted: 2010-10-27T10:13:51-07:00
by fmw42
I don't understand why you would have inconsistency unless perhaps you have more than one version of IM installed on your system or some of your images are corrupted. But this is beyond me. Someone more knowledgeable will need to help here.
Re: convert -crop
Posted: 2010-10-28T05:05:22-07:00
by ancou82
fmw42 wrote:I don't understand why you would have inconsistency unless perhaps you have more than one version of IM installed on your system or some of your images are corrupted. But this is beyond me. Someone more knowledgeable will need to help here.
I think the problem is solved.
Maybe wasn't working properly because I have more runtime executing before convert -crop and something went wrong, now I write process.waitfor() and everything seems to work fine.
Thanks a lot everybody