[HELP] Autocrop batch on photo ID
Re: [HELP] Autocrop batch on photo ID
Im sorry but what do you mean by: it should be a backquote to match what is left of convert
And how do i change it ?
And how do i change it ?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: [HELP] Autocrop batch on photo ID
Edit the file to replace 1 with `newbie1 wrote:Im sorry but what do you mean by: it should be a backquote to match what is left of convert
And how do i change it ?
#!/bin/sh
value=`compare -metric rmse -subimage-search 2.jpg 1.jpg null: 2>&1 | sed -n 's/^.*(\(.*\)).*$/\1/p'`
test=`convert xc: -format "%[fx:$value<$0.022?1:0]" info:`
if [ $test -eq 1]; then
convert 4.jpg oldid.jpg
else
convert 4.jpg newid.jpg
fi
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: [HELP] Autocrop batch on photo ID
Also remove the $ from your threshold or define a variable for the threshold. And put a space between -eq 1 and ]
or
#!/bin/sh
threshold=0.022
value=`compare -metric rmse -subimage-search 2.jpg 1.jpg null: 2>&1 | sed -n 's/^.*(\(.*\)).*$/\1/p'`
test=`convert xc: -format "%[fx:$value<$threshold?1:0]" info:1
if [ $test -eq 1 ]; then
convert 4.jpg oldid.jpg
else
convert 4.jpg newid.jpg
fi
#!/bin/sh
value=`compare -metric rmse -subimage-search 2.jpg 1.jpg null: 2>&1 | sed -n 's/^.*(\(.*\)).*$/\1/p'`
test=`convert xc: -format "%[fx:$value<$0.022?1:0]" info:1
if [ $test -eq 1]; then
convert 4.jpg oldid.jpg
else
convert 4.jpg newid.jpg
fi
or
#!/bin/sh
threshold=0.022
value=`compare -metric rmse -subimage-search 2.jpg 1.jpg null: 2>&1 | sed -n 's/^.*(\(.*\)).*$/\1/p'`
test=`convert xc: -format "%[fx:$value<$threshold?1:0]" info:1
if [ $test -eq 1 ]; then
convert 4.jpg oldid.jpg
else
convert 4.jpg newid.jpg
fi
Re: [HELP] Autocrop batch on photo ID
It still cannot work.
I did what you say and change it to:
I did what you say and change it to:
Code: Select all
#!/bin/sh
value=`compare -metric rmse -subimage-search 2.jpg 1.jpg null: 2>&1 | sed -n 's/^.*(\(.*\)).*$/\1/p'`
test=`convert xc: -format "%[fx:$value<0.022?1:0]" info:'
if [ $test -eq 1]; then
convert 4.jpg oldid.jpg
else
convert 4.jpg newid.jpg
fi
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: [HELP] Autocrop batch on photo ID
See the edited post above yours. You need to add a space between -eq 1 and ]
If that does not work, then try this test:
First try
compare -metric rmse -subimage-search rose: xc:red null:
does that produce any text on the terminal. If so then try
threshold=0.5
value=`compare -metric rmse -subimage-search rose: xc:red null: 2>&1 | sed -n 's/^.*(\(.*\)).*$/\1/p'`
test=`convert xc: -format "%[fx:$value<$threshold?1:0]" info:`
if [ $test -eq 1 ]; then
echo "less than"
else
echo "greater than"
fi
is should return "less than"
If that does not work, then try this test:
First try
compare -metric rmse -subimage-search rose: xc:red null:
does that produce any text on the terminal. If so then try
threshold=0.5
value=`compare -metric rmse -subimage-search rose: xc:red null: 2>&1 | sed -n 's/^.*(\(.*\)).*$/\1/p'`
test=`convert xc: -format "%[fx:$value<$threshold?1:0]" info:`
if [ $test -eq 1 ]; then
echo "less than"
else
echo "greater than"
fi
is should return "less than"
Re: [HELP] Autocrop batch on photo ID
Unfortunately, after changing it, it still cannot work.
Code: Select all
#!/bin/sh
threshold=0.022
value=`compare -metric rmse -subimage-search 2.jpg 1.jpg null: 2>&1 | sed -n 's/^.*(\(.*\)).*$/\1/p'`
test=`convert xc: -format "%[fx:$value<threshold?1:0]" info:`
if [ $test -eq 1 ]; then
convert 4.jpg oldid.jpg
else
convert 4.jpg newid.jpg
fi
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: [HELP] Autocrop batch on photo ID
You left out the $ before threshold. Variables in unix are always identified by a leading $ after they are created. Values (numbers) do not have the leading $. So either put $threshold in the test or use 0.022 without the $.newbie1 wrote:Unfortunately, after changing it, it still cannot work.Code: Select all
#!/bin/sh threshold=0.022 value=`compare -metric rmse -subimage-search 2.jpg 1.jpg null: 2>&1 | sed -n 's/^.*(\(.*\)).*$/\1/p'` test=`convert xc: -format "%[fx:$value<threshold?1:0]" info:` if [ $test -eq 1 ]; then convert 4.jpg oldid.jpg else convert 4.jpg newid.jpg fi
Re: [HELP] Autocrop batch on photo ID
Ok, i think there a problem with the first simple command.
When i tried out this:
I was using windows and it works.
But when i tried it out on my Ubuntu, the command line is also stuck.

I think this is the problem.
When i tried out this:
Code: Select all
compare -subimage-search -metric rmse newID.jpg student.jpg result.jpg
But when i tried it out on my Ubuntu, the command line is also stuck.

I think this is the problem.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: [HELP] Autocrop batch on photo ID
Quit the Terminal and start it again. Then does this return anything?
compare -metric rmse -subimage-search rose: xc:red null:
compare -metric rmse -subimage-search rose: xc:red null:
Re: [HELP] Autocrop batch on photo ID
This is the output:
Code: Select all
compare: images too dissimilar `ROSE' @ error/compare.c/CompareImageCommand/948.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: [HELP] Autocrop batch on photo ID
newbie1 wrote:This is the output:Code: Select all
compare: images too dissimilar `ROSE' @ error/compare.c/CompareImageCommand/948.
What version of IM are you using?
Try this
compare -metric rmse -subimage-search -dissimilarity-threshold 100% rose: xc:red null:
Note that rose has a colon after it. It is a special IM image.
Re: [HELP] Autocrop batch on photo ID
The version im using is:
Version: ImageMagick 6.6.9-7 2012-04-30 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP
The command works and this is the result:
Version: ImageMagick 6.6.9-7 2012-04-30 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP
The command works and this is the result:
Code: Select all
567.383 (0.00865772) @ 0,0
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: [HELP] Autocrop batch on photo ID
Then if that command works and you correct your code to match mine, it should work for you.
try this
value=`compare -metric rmse -subimage-search rose: xc:red null: 2>&1 | sed -n 's/^.*(\(.*\)).*$/\1/p'`
echo "$value"
Does that return anything?
try this
value=`compare -metric rmse -subimage-search rose: xc:red null: 2>&1 | sed -n 's/^.*(\(.*\)).*$/\1/p'`
echo "$value"
Does that return anything?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: [HELP] Autocrop batch on photo ID
Actually what you got does not match what I get:
compare -metric rmse -subimage-search -dissimilarity-threshold 100% rose: xc:red null:
143.673 (0.00219231) @ 32,20
So something is wrong with your version of IM, I suspect
I tried IM 6.6.9-7 and it hangs for me or takes way too long to return. So I suggest you upgrade your version of IM.
compare -metric rmse -subimage-search -dissimilarity-threshold 100% rose: xc:red null:
143.673 (0.00219231) @ 32,20
So something is wrong with your version of IM, I suspect
I tried IM 6.6.9-7 and it hangs for me or takes way too long to return. So I suggest you upgrade your version of IM.
Re: [HELP] Autocrop batch on photo ID
value=`compare -metric rmse -subimage-search rose: xc:red null: 2>&1 | sed -n 's/^.*(\(.*\)).*$/\1/p'`
echo "$value"
It does not return anything.
echo "$value"
It does not return anything.