Magick
Merge in batch
MAGICK_Merge_Vertical_jpg-png_v02.bat
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
set /p which="Do you want to merge jpg (type 1) or png (type 2) ? : "
if %which%==1 set format="jpg"
if %which%==2 set format="png"
set /p per=percent to resize (numeric) (make a copy it will overwrite your files)?:
echo Choose where your jpg are (choose 1 file):
:: file choose and get dir
set dialog="about:<input type=file id=FILE><script>FILE.click();new ActiveXObject
set dialog=%dialog%('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(FILE.value);
set dialog=%dialog%close();resizeTo(0,0);</script>"
for /f "tokens=* delims=" %%p in ('mshta.exe %dialog%') do set "input=%%p"
for /F %%i in ("%input%") do @set dir=%%~dpi
for /F %%i in ("%input%") do @set drive=%%~di
%drive%
cd "%dir%"
:: give info on what will be done
dir /a-d /b "*%format%" | find /c %format% > temp
set /p nfiles= < temp
::set /a nfiles=nfiles
del temp
:: resize
for %%p in (*.%format%) do magick convert %%p -resize %per%%% %%p
:: Merge
magick montage *.%format% -tile 1x%nfiles% -geometry +0+0 Merge.%format%
magick convert Merge.%format% Merge.pdf
echo DEBUG --------------------------
echo drive %drive%
echo dir %dir%
echo which %which%
echo format %format%
echo magick montage *.%format% -tile 1x%nfiles% -geometry +0+0 Merge.%format%
echo magick convert Merge.%format% Merge.pdf
Resize in batch
MAGICK_Resize_v01.bat
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
set /p which="Do you want to merge jpg (type 1) or png (type 2) ? : "
if %which%==1 set format="jpg"
if %which%==2 set format="png"
set /p per=percent to resize (numeric) ?:
echo Choose where your files are (choose 1 file):
:: file choose and get dir
set dialog="about:<input type=file id=FILE><script>FILE.click();new ActiveXObject
set dialog=%dialog%('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(FILE.value);
set dialog=%dialog%close();resizeTo(0,0);</script>"
for /f "tokens=* delims=" %%p in ('mshta.exe %dialog%') do set "input=%%p"
for /F %%i in ("%input%") do @set dir=%%~dpi
for /F %%i in ("%input%") do @set drive=%%~di
%drive%
cd "%dir%"
:: give info on what will be done
dir /a-d /b "*%format%" | find /c %format% > temp
set /p nfiles= < temp
::set /a nfiles=nfiles
del temp
for %%p in (*.%format%) do magick convert %%p -resize %per%%% %%~np_low.%format%
Level brightness
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
echo Choose where your jpg files are (choose 1 jpg):
:: file choose and get dir
set dialog="about:<input type=file id=FILE><script>FILE.click();new ActiveXObject
set dialog=%dialog%('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(FILE.value);
set dialog=%dialog%close();resizeTo(0,0);</script>"
for /f "tokens=* delims=" %%p in ('mshta.exe %dialog%') do set "input=%%p"
for /F %%i in ("%input%") do @set dir=%%~dpi
for /F %%i in ("%input%") do @set drive=%%~di
%drive%
cd %dir%
:: User input number of channel
set /p channel="At which level do you wanna set the white point ? (20 mean 20 percent of the actual, just test and MAKE A COPY OF YOUR FILE) : "
set /a channel=channel
:: give info on what will be done
dir /a-d /b "*jpg" | find /c "jpg" > temp
set /p nfiles= < temp
set /a nfiles=nfiles
set /a xfile=1
del temp
set /p tt=%nfiles% jpg will be processed, type Enter to continue.
:: convert in tiff and rename it
FOR /F "delims=" %%a IN ('dir /a-d /b "*jpg"') DO (
H:\TEMP\Software\ImageMagick-7.0.8-Q16\magick.exe convert %%a -level "0%%,%channel%%%,1" %%a
echo 1 more done ...
)
Flex files to tiff
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
echo Choose where your flex files are (choose 1 flex):
:: file choose and get dir
set dialog="about:<input type=file id=FILE><script>FILE.click();new ActiveXObject
set dialog=%dialog%('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(FILE.value);
set dialog=%dialog%close();resizeTo(0,0);</script>"
for /f "tokens=* delims=" %%p in ('mshta.exe %dialog%') do set "input=%%p"
for /F %%i in ("%input%") do @set dir=%%~dpi
for /F %%i in ("%input%") do @set drive=%%~di
%drive%
cd %dir%
mkdir TIFF
:: User input number of channel
set /p channel="How many Channel you have ? "
set /a channel=channel
:: give info on what will be done
dir /a-d /b "*flex" | find /c "flex" > temp
set /p nfiles= < temp
set /a nfiles=nfiles
set /a xfile=1
del temp
set /p tt=%nfiles% flex will be processed, type Enter to continue.
:: convert in tiff and rename it
FOR /F "delims=" %%a IN ('dir /a-d /b "*flex"') DO (
H:\TEMP\Software\ImageMagick-7.0.8-Q16\magick.exe convert %%a -set filename:f "%%t_%%s" +adjoin "TIFF\%%[filename:f].tif"
dir /b "*.tif" | find /c "%%~na" > temp
set /p howmany= < temp
set /a howmany=!howmany!
del temp
set /a loopfi=howmany/channel
:: order dir by date /od
cd TIFF
FOR /F "delims=" %%b IN ('dir /a-d /b /od "%%~na*tif"') DO (
FOR /l %%c IN (1, 1, !loopfi!) DO (
FOR /l %%d IN (1, 1, %channel%) DO (
ren %%b TIFF\%%~na_ch%%d_fi%%c.tif
)
)
)
cd ..
echo !xfile! flex / !nfiles!
)
Convert
Image to matrice - cut the image in pieces
convert image.jpg -crop 50%x50% +repage piece_%d.jpg
flex to single tif with regex
magick.exe convert %input% -set filename:f "%%t_%%s" +adjoin "%%[filename:f].tif"
From to (jpg, pdf …), rotate …
magick mogrify -format jpg *.ppm
mogrify -format pdf *jpg
mogrify -rotate "270" *jpg
jpg to pdf
in 1 folder, 1 jpg for 1 page in a pdf
:: Will convert all jpg from a folder in a page in a pdf
for /F "usebackq delims=" %A in (`ls ^|grep -s jpg ^| tr "\n" " "`) do convert -quality 85 %A output.pdf