Saving disk space

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
cbr2print
Posts: 3
Joined: 2016-08-31T20:22:04-07:00
Authentication code: 1151

Saving disk space

Post by cbr2print »

Im a bit litle confused: In fact what I need is to resize a batch of images to a fixed print height in order to cheat my chunky A4 Canon mp 250 to do the work without wasting paper or adding HUGE margins.
So im writing a batch file over windows xp to set every image to its final size at its final configuration offset, the matter is that reescaling an image of a few kb to an A4 size increase its size in order of 10ths of Mb (I dont know why as im trying to not touch resolution).
The idea is to print cbr comics at maximum posible size so when i bend the page for printing the comic dont look extra small.
Anyone help me? Im a bit desoriented, thanks.
cbr2print
Posts: 3
Joined: 2016-08-31T20:22:04-07:00
Authentication code: 1151

Re: Saving disk space

Post by cbr2print »

Also for doing it faster!
cbr2print
Posts: 3
Joined: 2016-08-31T20:22:04-07:00
Authentication code: 1151

Re: Saving disk space

Post by cbr2print »

Here is my batch file:

Code: Select all

setlocal enabledelayedexpansion

::Crear carpeta temporal para alojar archivos
set pagewidht=12
set pageheight=82
set folder=%tmp%\scale_%random%
md %folder%
:: Copiar archivos objeto a la carpeta temporal
rem set pages=0
rem for %%x in ("%*\*.jpg") do (set /a pages=!pages!+1
rem copy "%*\%%x "  %folder%\!pages!.jpg)
copy "%*\*.jpg" %folder%
rem set/a fpages=%pages%*100
::if not %pages%/4==%fpages%/400 (echo faltan paginas
::set error=1)
rem if %error%=1 goto end
:: Calculo del numero de paginas (redundante dentro del proceso global)
set pages=0
cd %folder%
for %%x in ("%folder%\*.jpg") do set /a pages=!pages!+1
::Hallar el archivo de resolucion mayor
for %%x in ("%folder%\*.jpg") do ("Y:\Archivos de programa\ImageMagick-7.0.2-Q16\identify" -verbose %folder%\1.jpg|find "Res"|find /v "exif">"%tmp%\scale.txt"
for /f  "tokens=2" %%a in (%tmp%\scale.txt) do echo %%a >%tmp%\scale.txt
for /f  "tokens=1,2 delims=x" %%b in (%tmp%\scale.txt) do (
set wres%%~nx=%%b
set hres%%~nx=%%c)
)
set gwres=0
set ghres=0
::Convertir todos los archivos a la resolucion maxima
for %%x in ("%folder%\*.jpg") do if  !wres%%~nx!*!hres%%~nx! gtr %gwres%*%ghres% (
set  gwres=!wres%%~nx!
set  ghres=!hres%%~nx!
)
rem for %%x in ("%folder%\*.jpg") do if  !hres%%~nx! gtr %ghres% set  ghres=!hres%%~nx!
rem for %%x in ("%folder%\*.jpg") do "Y:\Archivos de programa\ImageMagick-7.0.2-Q16\convert" "%%x" -resample %gwres%x%ghres% "%%x"
::Y justificar las dimensiones al tamaño final de impresion
set /a height=%ghres%*%pageheight%
rem for %%x in ("%folder%\*.jpg") do set /a width%%~nx=!wres%%~nx!*850
for %%x in ("%folder%\*.jpg") do "Y:\Archivos de programa\ImageMagick-7.0.2-Q16\convert" "%%x" -resize x%height% "%%x"
::Hallar el ancho mayor 

set width=0
for %%x in ("%folder%\*.jpg") do (
"Y:\Archivos de programa\ImageMagick-7.0.2-Q16\identify" -verbose "%%x"|find "Geometry:">"%tmp%\scale.txt"
for /f  "tokens=2" %%a in (%tmp%\scale.txt) do echo %%a >%tmp%\scale.txt
for /f  "tokens=1 delims=x" %%b in (%tmp%\scale.txt) do if  !width!  lss %%b set width=%%b
echo !width!
)

echo %height%
::Armado del tabloide mediante tratamento diferencial (izquierda-derecha)
for %%x in ("%folder%\*.jpg") do "Y:\Archivos de programa\ImageMagick-7.0.2-Q16\convert" "%%x" -gravity center -extent %width%x%height% "%%x"
set pages=0
for %%x in ("%folder%\*.jpg") do set /a pages=!pages!+1
::ÇProceso local?
md %folder%\offset\
pushd
set drive=%cd:~,2%
cd %folder%
%tmp:~,2%
set /a es=%pages%/2
set /a ei=%es%+1
set op=1
for /l %%x in (1,2,%pages%) do "Y:\Archivos de programa\ImageMagick-7.0.2-Q16\convert" %%xb.jpg %%x.jpg +append %folder%\offset\%%x.jpg
for /l %%x in (2,2,%pages%) do "Y:\Archivos de programa\ImageMagick-7.0.2-Q16\convert" %%x.jpg %%xb.jpg +append %folder%\offset\%%x.jpg
::For /l %%x in (1,1,%ei%) do (set /a y=%pages%+1-%%x
::set /a op=!op!*-1
::if op>0 "Y:\Archivos de programa\ImageMagick-7.0.2-Q16\convert" %%x.jpg !y!.jpg +append %folder%\offset\%%x.jpg
::if op<0 "Y:\Archivos de programa\ImageMagick-7.0.2-Q16\convert" !y!.jpg %%x.jpg  +append %folder%\offset\%%x.jpg
::)
rem rundll32    shimgvw.dll    ImageView_PrintTo /pt   xxx.png   "Canon MP250 series Printer"

Post Reply