Making Chop-o-Matic more adaptive ?
Hello dear Photoshop fellows,
I am working on webcomics scroll documents (960 x 95000 + px), and the most tedious part of the job consists in slicing the scroll into 1280 pixels height JPGs files... For the moment, the team laboriously worked with a Photoshop Action, but it needed to be relaunched and manually numbered for every file.
Typically a task for a script, you would tell me !
I did some Python programming by the past, but none on Javascript, neither with Photoshop SDK.
After a first theorical design for the script I needed, I stumbled here upon the Chop-O-Matic script (this page ), which makes 90% of the job, which is great, but i need to tweak it, based on my needs. I'll leave my algorithm sketch at bottom of this message.
What I need to suppress from chop-o-matic :
- dialog window ;
- no need to slice across.
What I need to modify in chop-o-matic :
- instead of a fixed amount of slices, the new script should make the maths itself, like :
numberOfSlices = math.ceil(currentDocumentHeight / 1280)
The total height of main scroll varies from episode to episode, but every slice of it would always be 1280 px tall.
- the current version of chop-o-matic outputed 1279 px tall files, instead of 1280 px. ...
I guess it is due to integer approximation of current version of chop-o-matic.
- I need to change JPEG output so that it is quality 10, progressive scan with 3 passes ;
- The numbering of created files just need to be "000-999.jpg" template.
And that's it. Apart from specified above, the existing script does the job.
Kudos to Paul_Riggot, by the way. 🙂
This is my initial script design, before discovering Chop-o-Matic :
Focus on open document ;
Duplicate and save a PSD copy at the same level ;
Flatten current document (no dialog) ;
Focus on duplicated document ;
var sliceHeight = 1280
var sliceSerial = 000
var nameSerial = 000
get current document's height (in pixel) ;
//pre-slicing calculation...
var sliceSerial = Math.ceil(doc height / SliceHeight)
//start of loop
if (sliceSerial > 1) {
duplicate current document ;
focus on newly created document ;
Set canvas size to 1280 px height, with relative anchor top center ;
Save current document to JPEG, quality 10, progressive scan, 3 passes, located at ../Sliced_JPGs/, named "nameSerial.jpg" , (no dialog displayed) ;
var sliceSerial --
var nameSerial ++
close current document, NOSAVE ;
}
else {
duplicate current document ;
focus on newly created document ;
Save current document to JPEG, quality 10, progressive scan, 3 passes, located at ../Sliced_JPGs/, named "nameSerial.jpg" , (no dialog displayed) ;
close current document, NOSAVE ;
}
//end of loop
// variables reinitialization
var sliceSerial = 000
var nameSerial = 000
Close current document //the long scroll
Thanks for your attention !
