Page 1 of 1
How to create a square thumb ?
Posted: Mon Jun 25, 2012 2:16 pm
by Amade
Hi
I need to create to create a lot (>10 000) of thumbs from several pictures, with different sizes and orientations.
The result could be : 120 x 120 in the original orientation, with truncature of the rectangular parts to become a square.
Like this :
- 1204 x 840 ---resize-ratio---> 172 x 120 ----canvas center---> 120 x 120
- 840 x 1204 ---resize-ratio---> 120 x 172 ----canvas center---> 120 x 120
- 600 x 800 ---resize-ratio---> 120 x 160 ----canvas center---> 120 x 120
Do you have an idea to manage the different orientations ?
Thanks
Alain
Re: How to create a square thumb ?
Posted: Mon Jun 25, 2012 10:00 pm
by XnTriq
I believe this can only be done in XnView.
What's missing though is an option to crop images of varying sizes and orientations in a centered fashion.
Re: How to create a square thumb ?
Posted: Tue Jun 26, 2012 1:15 am
by XnTriq

Solved?
Re: How to create a square thumb ?
Posted: Tue Jun 26, 2012 11:50 am
by Amade
Thank you for your answer.
I understood, it's mandatory to use the GUI Xnview to start the conversion.
Actually, I need a command line to insert it in a batch process script.
I found an another method below.
Thank's
Alain
_bat file________________________________________________________________
rem %1 %2 %3 voir ci-dessous
rem fichier texte temporaire pour traitement taille
set tmpfile=%1
rem repertoire destinataire
set repcible=%2
rem nom complet du fichier image à traiter
set img=%3
rem nconvert programme
set ncv=F:\Nconvert\nconvert
rem taille du carré
set cote=120
Rem extraction largeur/hauteur
"%ncv%" -info "%img%"|find "Width ">"%tmpfile%"
for /f "tokens=2 delims=:" %%a in ('
type "%tmpfile%"') do set wd=%%a
"%ncv%" -info "%img%"|find "Height ">"%tmpfile%"
for /f "tokens=2 delims=:" %%a in ('
type "%tmpfile%"') do set ht=%%a
for %%f in ("%tmpfile%") do if exist %%f del %%f
set wd=%wd: =%
set ht=%ht: =%
Rem creation des thumb carrés dans le repertoire cible suffixés par "-sq"
if %wd% LSS %ht% (set presize=%cote% 0) ELSE (set presize=0 %cote%)
%ncv% -ratio -resize %presize% -canvas %cote% %cote% center -o "%repcible%\%%-sq.jpg" "%img%"
Re: How to create a square thumb ?
Posted: Tue Jun 26, 2012 10:30 pm
by XnTriq
Thank you for posting your script, Alain

I'm sure other users will find it very useful.