Hello I just wanted to ask if this is possible to do:
I have an image opened and create selection (for example marquee)
Now run the script which:
Record that selection is 14cm wide (lets assume that all images I use are 72PPI)
ask user to input value, for example 173cm
then it calculates 173/14 = 12,35
and change image size by 1235% (which comes from previous calculation)
What can be done, what can't? what are limitations in such example?
Thank you for your help
Resizing an Image by selection size
Re: Resizing an Image by selection size
Code: Select all
$.level = 0, preferences.rulerUnits = Units.CM
try {
(bnd = (aD = activeDocument).selection.bounds)[2] - bnd[0], v = prompt('Enter the value:', '');
(/^\d*$/).test(v) ? (f = v / 14, aD.resizeImage(aD.width * f, aD.height * f)) : alert('That wasn\'t number!')
}
catch (errSel) {alert('Make selection to preceed...')}
Re: Resizing an Image by selection size
It works great, fast and exactly as I described thank you
What should I put instead of "14" which is static value, to divide not by 14 but by current selection width?
EDIT:
Ok I made it
this will now work with value from selection width Once again thank you for your help
Code: Select all
f = v / 14
EDIT:
Ok I made it
Code: Select all
$.level = 0, preferences.rulerUnits = Units.CM
try {
as = (bnd = (aD = activeDocument).selection.bounds)[2] - bnd[0];
v = prompt('Docelowa szerokość:', '');
(/^\d*$/).test(v) ? (f = v / as, aD.resizeImage(aD.width * f, aD.height * f)) : alert('Podawaj tylko liczby.')
}
catch (errSel) {alert('Najpierw zaznacz element')}
Re: Resizing an Image by selection size
Yes I was too fast writing that code, so I forgot to change 14 to proper selection in document. But I did another mistake! I didn't add '.value' part at end of selection width. Use corrected code once again to get proper result this time:
Code: Select all
$.level = 0, preferences.rulerUnits = Units.CM
try {
if ((/^\d*$/).test(v = prompt('Enter the value:', ''))) {
f = v / ((bnd = (aD = activeDocument).selection.bounds)[2] - bnd[0]).value
aD.resizeImage(aD.width * f, aD.height * f)
}
else alert('That wasn\'t number!')
}
catch (errSel) {alert('Make selection to preceed...')}
Re: Resizing an Image by selection size
Thank you Works great