Page 1 of 1

Photoshop script to crop/canvas size by specific dimension

Posted: Wed Feb 20, 2019 12:20 pm
by dragosh29
Hello to everyone

I have several images called this way "100x200_120x220mm". The first sequence, 100x200, represents the visible size, and 120x220 represents the total size of the image. They are inserted into a frame. I would need a script to cut the image to the visible size. Script must look for the size in the file name. This is possible. Thank you.

Re: Photoshop script to crop/canvas size by specific dimension

Posted: Wed Feb 20, 2019 9:41 pm
by Kukurykus
Yes that's possible, but for clarity show examplary image, because I'm not sure is the frame hidden beyound canvas or it inside of canvas but you want to resize only part inside visible frames.

Re: Photoshop script to crop/canvas size by specific dimension

Posted: Thu Feb 21, 2019 9:46 am
by dragosh29
Hi Kukurykus, thanks for your reply.

https://www.dropbox.com/s/6f3b2a6tptp95 ... 5.jpg?dl=0

Forget that the images are inserted into a frame. It does not matter now. The idea is that these images, made to the size they are printed, must be sent to the customer for approval, and they want to see only the visible size, not the total size. They have trouble understanding how the layout looks at the visible size. Till now this images had been cropped manually. Hundreds of images.

So, this image has the total size of 355x235mm. The red border has the size of 300x200mm. The script must read 300x200 in the file name. "a"x"b"_"c"x"d". No matter how many digits "a" and "b" have. I suspect that you can use "_" as a delimiter.

In conclusion, I need to cut images at the small size, of course without changing the resolution.

Tx

Re: Photoshop script to crop/canvas size by specific dimension

Posted: Tue Mar 05, 2019 5:54 am
by AnilTejwani
dragosh29 wrote: ↑Thu Feb 21, 2019 9:46 am So, this image has the total size of 355x235mm. The red border has the size of 300x200mm. The script must read 300x200 in the file name. "a"x"b"_"c"x"d". No matter how many digits "a" and "b" have. I suspect that you can use "_" as a delimiter.
Try the below code.

Code: Select all


// i assume filename will be in format 'a'x'b'_'c'x'd'.jpg and will not contain any mm/cm/px etc in fileName
var fileName = '300x200_355x235.jpg';
var pieces = fileName.split('_');
var visibleSize = pieces[0];
var vsPieces = visibleSize.split('x');
alert('Visible dimensions of file ' + fileName + '\nWidth: '+ vsPieces[0] + '\nHeight: ' + vsPieces[1]);
Let me know if that helped.

Cheers