edit - my os and ver sion is first machine
Code: Select all
PsInfo v1.77 - Local and remote system information viewer
Copyright (C) 2001-2009 Mark Russinovich
Sysinternals - www.sysinternals.com
System information for \\HPWS02:
Uptime: 4 days 22 hours 16 minutes 26 seconds
Kernel version: Windows 7 Professional, Multiprocessor Free
Product type: Professional
Product version: 6.1
Service pack: 0
Kernel build number: 7601
Registered organization: Hewlett-Packard Company
Registered owner:
IE version: 9.0000
System root: C:\Windows
Processors: 8
Processor speed: 3.3 GHz
Processor type: Intel(R) Xeon(R) CPU E3-1245 V2 @
Physical memory: 3988 MB
Video driver: Intel(R) HD Graphics
c:\pyscripts>convert -version
Version: ImageMagick 6.8.6-8 2013-08-04 Q8 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: bzlib djvu fftw fontconfig freetype jng jp2 jpeg lcms lzma openexr pa
ngo png ps tiff webp x xml zlib
Code: Select all
PsInfo v1.77 - Local and remote system information viewer
Copyright (C) 2001-2009 Mark Russinovich
Sysinternals - www.sysinternals.com
System information for \\PROC01:
Uptime: 2 days 17 hours 47 minutes 42 seconds
Kernel version: Windows 7 Professional, Multiprocessor Free
Product type: Professional
Product version: 6.1
Service pack: 0
Kernel build number: 7601
Registered organization:
Registered owner: Windows User
IE version: 9.0000
System root: C:\Windows
Processors: 16
Processor speed: 2.3 GHz
Processor type: Intel(R) Xeon(R) CPU E5620 @
Physical memory: 0 MB
Video driver: NVIDIA Quadro NVS 295
b:\pyscripts>convert -version
Version: ImageMagick 6.8.9-10 Q8 x64 2014-11-02 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo freetype jbig jng jp2 jpeg lcms lqr pangocairo png ps rsv
g tiff webp xml zlib
Code: Select all
Version: ImageMagick 6.6.0-4 2012-05-02 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP
I read this thread http://www.imagemagick.org/Usage/forum_ ... 62&p=73079 and this info page http://www.imagemagick.org/Usage/distorts/ and it looks like something I would be looking for, that is - and internal crop of the scanned image after it has been rotated, such that it would contain the largest shape with same aspect ratio.
I have attached LQ jpgs images for vewing and my script (on windows) .
source image (it has 0.783292 degrees of rotation) 0003x.jpg
Image when ran through deskew 60% ( i find 60 works better than 40 most times) (as an aside I need the deskew to be 'center weighted' -- is that possible ?, it seems the deskew weights it's decision to the top left ??(note not this image) maybe a topic for another discussion) - note the white triangles - 0003x_deskew_60.jpg
Image ran through simple SRT rotate - this extends the image edges which is sometime Ok, but generally not desirable. + or - still exhibits the same issue to a different degree. (shaving is a crude method to resolve this but the amount of shave required changes image by image) 0003x_plus_distort.jpg / 0003x_minus_distort.jpg
Here is the script that I used, and below is the output image. It significantly crops in the page. 0003x_SRT_rotate_output.png
Code: Select all
@echo off
SETLOCAL
REM angle=20
REM ratio=`convert rose: -format \
REM "%[fx:aa=$angle*pi/180; min(w,h)/(w*abs(sin(aa))+h*abs(cos(aa)))]" \
REM info:`
REM crop="%[fx:floor(w*$ratio)]x%[fx:floor(h*$ratio)]"
REM crop="$crop+%[fx:ceil((w-w*$ratio)/2)]+%[fx:ceil((h-h*$ratio)/2)]"
REM convert rose: -set option:distort:viewport "$crop" \
REM +distort SRT $angle +repage rotate_internal.png
REM convert rose: -distort SRT "%[fx:aa=20*pi/180;(w*abs(sin(aa))+h*abs(cos(aa)))/min(w,h)], 20" rotate_correction.png
FOR /F %%B IN ('convert %1 -deskew 60%% -format %%[deskew:angle] info:') DO (
SET angle=%%B
ECHO angle %%B
)
REM SET angle=45
FOR /F "usebackq" %%B IN (`convert %1 -format "%%[fx:aa=%angle%*pi/180; min(w,h)/(w*abs(sin(aa))+h*abs(cos(aa)))]" info:`) DO (
SET ratio=%%B
ECHO ratio %%B
)
REM SET ratio=0.5
SET crop1=%%[fx:floor(w*%ratio%)]x%%[fx:floor(h*%ratio%)]
SET crop=%crop1%+%%[fx:ceil((w-w*%ratio%)/2)]+%%[fx:ceil((h-h*%ratio%)/2)]
convert %1 -set option:distort:viewport "%crop%" +distort SRT "%angle%" rotate_internal.png
Any questions let me know -- It seems the the script part fx that calculates the ratio /w/h seems to be significantly reducing the veiwport width for the reason of which i do not know.
http://81.143.7.209/0003x.zip