new Scanner, result for size from convert not the same....

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
derilzemer
Posts: 21
Joined: 2011-12-12T12:18:16-07:00
Authentication code: 8675308

new Scanner, result for size from convert not the same....

Post by derilzemer »

Hi @ all,
my english isn't then a year ago so please forgiving :(
I'm using a script to cut pictures from a scan with a former plate. The old scan are made with a brother 9420-CN. The script has to do the follwing

echo " convert $aktiv_dir/$aktiv_file -crop 1x1\@ +repage -bordercolor black -border 1 -resize 1024x -fuzz 80% -fill none -draw \"matte 0,0 floodfill\" -trim +repage $aktiv_dir/${datei_name}.png" >>doit.sh
echo " convert $aktiv_dir/$aktiv_file -crop 4x2\@ +repage -bordercolor black -border 1 -fuzz 95% -trim +repage -resize 250x $aktiv_dir/${datei_name}_%d.png" >>doit.sh
echo " convert $aktiv_dir/${datei_name}_*.png -bordercolor black -border 1 -fuzz 80% -fill none -draw \"matte 0,0 floodfill\" -trim +repage $aktiv_dir/${datei_name}_%d.png" >>doit.sh
echo " convert $aktiv_dir/${datei_name}_*.png -resize 125x $aktiv_dir/t_${datei_name}_%d.png" >>doit.sh
echo " convert $aktiv_dir/${datei_name}.png -resize 285x $aktiv_dir/t_${datei_name}.png" >>doit.sh

every single picture have a size with 250. It depends between 250/380 and 250/384. Everything works fine.
But now I have to buy a new scanner because the old one is out of order, HPOfficejet 8660. If i make a scan with the same picture as with the old scanner
and use the script to cut the pictures, every picture has an other size. No one have 250x38x!! It depends between 222/344 to 249x368

Nothing has changed only the Scanner and the software. Is it possible, that the scanner software deliver Headerinformation inside the jpeg that ImageMagick handel the pictures different? Wich option do i have with convert, that i can ignore these informations?

thanks for all hints and
regards from Germany
Andreas
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: new Scanner, result for size from convert not the same..

Post by snibgo »

What size (width and height) were the scans from the old scanner? And from the new scanner?
snibgo's IM pages: im.snibgo.com
derilzemer
Posts: 21
Joined: 2011-12-12T12:18:16-07:00
Authentication code: 8675308

Re: new Scanner, result for size from convert not the same..

Post by derilzemer »

Hi,
sorry i forgot to post this information

Old one: w 3437 x h 2480
New one: w 3507 x h 2550
8 bpp Colordepth
YCbCr Colormodel
24 Bitdepth
300 dpi

First i think also the problem causes on the size from the original scan. I changed from full-scale Scan range to A4 210/297 mm but the result is the same.

regards
Andreas
derilzemer
Posts: 21
Joined: 2011-12-12T12:18:16-07:00
Authentication code: 8675308

Re: new Scanner, result for size from convert not the same..

Post by derilzemer »

Hi,

i think i have news to get better understanding for the problem.
Please look at http://derilzemer.de/ and go over the left frame Test --> Resize Problem.
If there is any information necessary, please let me know. Hopefully anyone can help to fix thios problem.

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

Re: new Scanner, result for size from convert not the same..

Post by fmw42 »

The problem seems to be that the fuzz value is too high. That causes the black to leak into your image on the top right and fills it with black. Since your good and bad examples use different car images, it is hard to know exactly what the image should look like, since all we see is black.

If this is not the problem, then please explain further and post an example to show clearly what the problem is?
derilzemer
Posts: 21
Joined: 2011-12-12T12:18:16-07:00
Authentication code: 8675308

Re: new Scanner, result for size from convert not the same..

Post by derilzemer »

Hi,
sorry i think my english is one of the problem to explain it correctly. I'll try it again hopefully you understand it
At the moment, i scan pictures with 3 different former plates. The new situation is, that i would like to scan the picture with A4 (210/297 mm). Then i would like to cut 8 single pictures from the scan like this http://derilzemer.de/producer/Testseiten/scan.htm.
Then i make a process with the script
  • echo " convert $aktiv_dir/$aktiv_file -crop 1x1\@ +repage -bordercolor black -border 1 -resize 768x -fuzz 20% -fill none -draw \"matte 0,0 floodfill\" -trim +repage $aktiv_dir/${datei_name}.png"
  • echo " convert $aktiv_dir/$aktiv_file -crop 2x2\@ +repage -bordercolor black -border 1 -fuzz 20% -trim +repage -resize 256x $aktiv_dir/${datei_name}_%d.png"
  • echo " convert $aktiv_dir/${datei_name}_*.png -bordercolor black -border 1 -fuzz 20% -fill none -draw \"matte 0,0 floodfill\" -trim +repage $aktiv_dir/${datei_name}_%d.png"
But the result wasn't so good (look at the result) http://derilzemer.de/producer/Testseite ... y_prob.htm.
I don't know, what the problem is.

Now the question is. Is it possible that i cut the 4 single pictures from the scan first, then i resize the 4 pics and then the transparency?
If it is, what are the command with convert to make this?

Hope its better to understand :(

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

Re: new Scanner, result for size from convert not the same..

Post by fmw42 »

I think your crop method is generating different sizes for each card that it extracts. The fuzz value is trimming more from one image than the others. You need to pad or crop the individual images to some common size before resizing them.

You might like to try my script, multicrop, at the link below (if on unix). It may be slow, but is convenient.

For example using your image, 298_1967_1.png, I first pad with 10 pixel black border.

convert 298_1967_1b.png -bordercolor black -border 10 298_1967_1b_parts.png

Then I run

multicrop -g 5 -f 20 -u 1 298_1967_1b.png 298_1967_1b_parts.png

This produces 4 images -- one for each card. At this point, you should check the sizes and either pad to the size of the largest or crop to the size of the smallest.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: new Scanner, result for size from convert not the same..

Post by snibgo »

I think you want two steps:

1. Break the panel into four images.

2. For each image, remove the border around the card: make it transparent and trim.


Step 1 is easy:

Code: Select all

convert 298_1967_1.jpg -crop 2x2@ car_%%d.png
Now we have car_0.png, car_1.png, car_2.png and car_4.png.

Step 2 can be:

Code: Select all

convert ^
  car_0.png ^
  -bordercolor black -border 1 ^
  ( +clone ^
    -blur 0x3 ^
    -fuzz 50%% -fill None -draw "matte 0,0 floodfill" ^
  ) ^
  -compose CopyOpacity -composite ^
  -trim +repage ^
  car_b_0.png
This makes a mask from the image, which is transparent around the edge. Blur and fuzz removes the noise.

car_b_0.png is trimmed, with transparent corners.

Repeat this command for the other three cars. Resize if you want.
snibgo's IM pages: im.snibgo.com
derilzemer
Posts: 21
Joined: 2011-12-12T12:18:16-07:00
Authentication code: 8675308

Re: new Scanner, result for size from convert not the same..

Post by derilzemer »

Hi Fred,
thanks for reply. Okay I use imagemagick - 6.6.9.1-1 on a Linux DiskStation 3.2.40. I can use crop woithout problems but i can't use multicrop
I test it with my script with the follwing

echo " convert $aktiv_dir/$aktiv_file -bordercolor black -border 10 $aktiv_dir/${datei_name}_%d.png" >>doit.sh
echo " multicrop -g 5 -f 20 -u 1 $aktiv_dir/${datei_name}_*.png $aktiv_dir/${datei_name}_%d.png" >>doit.sh

multicrop: command not found
So is it a modul from ImageMagick or what do i have to do that i can use multicrop?

Thanks
Andreas
derilzemer
Posts: 21
Joined: 2011-12-12T12:18:16-07:00
Authentication code: 8675308

Re: new Scanner, result for size from convert not the same..

Post by derilzemer »

Hi Snibgo,

i test your offer but the result is not that i want. Look at it http://derilzemer.de/producer/Testseiten/newtest.htm
Freds offer with multicrop sounds good but at the moment i can't use it because i don't have multicrop. I have to check, what i have to do that i can use multicrop
or wich package or lib i have to install on the system.

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

Re: new Scanner, result for size from convert not the same..

Post by fmw42 »

echo " multicrop -g 5 -f 20 -u 1 $aktiv_dir/${datei_name}_*.png $aktiv_dir/${datei_name}_%d.png" >>doit.sh
The script will only process one image at a time. No wild cards are allowed.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: new Scanner, result for size from convert not the same..

Post by fmw42 »

Freds offer with multicrop sounds good but at the moment i can't use it because i don't have multicrop. I have to check, what i have to do that i can use multicrop
or wich package or lib i have to install on the system.
Simply download the bash unix shell script and follow the directions on my web site. See pointers. Then just open a terminal window and paste the command I gave above using just one input image and one named output image. The multiple output images will get named with appended -0...-N.

Try the same example I posted above with the same input image.

However, all this will do is crop out the 4 images into separate images with minimal surrounding black. Follow my suggestions above to follow up with a crop or pad to the same size results.

Alternately resize the input image before using the script and just get the resulting 4 images.

Be sure to pad the input with some black using -bordercolor black -border 10 so that there is no non-black colors at the edges of the input.
derilzemer
Posts: 21
Joined: 2011-12-12T12:18:16-07:00
Authentication code: 8675308

Re: new Scanner, result for size from convert not the same..

Post by derilzemer »

Hi,
thanks for your comment. I will test it the next time. At the moment i'm very busy but I let you know whats going if I test your script.
regards
Andreas
afeesn
Posts: 1
Joined: 2014-07-17T00:08:48-07:00
Authentication code: 6789

Re: new Scanner, result for size from convert not the same..

Post by afeesn »

result of convert size is not good
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: new Scanner, result for size from convert not the same..

Post by fmw42 »

afeesn wrote:result of convert size is not good

What is your question? The above is rather cryptic

What is the exact command? Can you provide the input image and output image you get? What version of IM and what platform.

Please do not tack on a new topic to an old thread. Please start a new thread and read viewtopic.php?f=1&t=9620
Post Reply