Copy link to clipboard
Copied
Hi everyone, my first post in this community! I'm looking for a bit of help with scripting to automate copying files please.
I've been writing a simple script to copy selected thumbnails from bridge to a different folder. I'm completely new to javascript so feeling my way through - one problem that I've run into is that when the call is made to create the new bitmap file, the orientation information is lost so portrait images appear as landscape after they're copied to the new location.
Any suggestions as to how I can get the orientation information from the source file (the one that's been selected) prior to creating the new file? If I can get that then I can check if the newly created bitmap needs to be rotated but I can't work out how to access it. Here's what I've got so far:
Ah that's useful to know, thank you Lumigraphics! I'm so new to this that even the most basic calls need a few pointers!
I managed to navigate the rotation problem by looking a bit more closely at the JS guide BitmapData functions and used:
var bm = new BitmapData(thumbs[i].spec);
var rotatedBM=bm.rotate(-90);
rotatedBM.exportTo(new File(exportFilePath));
Doubtless not the tidiest (or most efficient) way to do it but at least I've solved this particular problem (well I think I have!). I really do n
...Copy link to clipboard
Copied
Lumagraphis are resident script guru who lurks here should be able to help you.
Copy link to clipboard
Copied
var orientation = Thumb.rotation;
Copy link to clipboard
Copied
Thank you, I've looked at orientation and that was my intention - but it won't work because once the new file has been created the orientation data seems to be removed, so the only way to get it the right way up is by doing it manually?
Copy link to clipboard
Copied
I don't follow as you can reference the old file to the new file....
NewThumb.rotation = OldThumb.rotation;
Copy link to clipboard
Copied
Ah I follow now, thank you SuperMerlin. Bear in mind I'm very unfamiliar with Javascript so feeling my way through at the moment 🙂
So I've now got:
That does show var bm as having a rotation of -90 but it doesn't work unfortunately, the file is created without the orientation info (when I check the file info in Bridge it shows the orientation as 1(Normal).
Any idea as to why the orientation isn't being picked up in the created file please? I've also tried:
bm.rotate(-90);
on a test file in known portrait orientation and that doesn't work either.
Copy link to clipboard
Copied
Have you tried seting the rotation after the bitmap has been exported?
Copy link to clipboard
Copied
Thanks SuperMerlin, yes I think that would work, I know this is a daft question but can you give me a clue re how to access the exported file to do that please?
Copy link to clipboard
Copied
Untested, but you could try...
var bm = new BitmapData(thumbs[i].spec);
if(bm instanceof BitmapData)
{
// create the path and file name
var exportFilePath = destinationFolder + "/" + thumbs[i].name;
bm.exportTo(new File(exportFilePath));
var th = new Thumbnail(exportFilePath);
th = thumbs[i].rotation;
}
Copy link to clipboard
Copied
Thanks SuperMerlin, tried that, not sure why but it doesn't seem to like:
var th = new Thumbnail(exportFilePath);
Just a thought, can I get Bridge to go to the folder defined in var exportFilePath? I'll be able to flip them manually from there if there's no way to do it in the script.
Copy link to clipboard
Copied
Try...
var th = new Thumbnail(new File(exportFilePath));
Copy link to clipboard
Copied
Thanks for that SuperMerlin, it runs through ok now but still no luck with the rotation though 😞
Copy link to clipboard
Copied
Why not just copy the files? You don't need to create a whole new bitmap.
Copy link to clipboard
Copied
I can't work out how to just copy the files through the script. Any advice on how to do that please?
Copy link to clipboard
Copied
Thanks for your suggestion. One point that's worth adding is that I may want to create different sizes of the files.
The reason I'm creating this script is to quickly process files at a point of sale for customers. So they purchase a digital copy of a file (in either low or high resolution) and the script uploads it to a specific Dropbox folder. I have an assistant and going through the process of selecting the files and manaually copying them can potentially introduce errors.
Copy link to clipboard
Copied
Ok, I wondered if resizing was why. I publish a JPEG export script that resizes files and have to create bitmaps to do so but I haven't had problems with rotation.
To copy a file, use this syntax:
var myThumbs = app.document.selections;
var myFolder = Folder('~/Desktop/');
myThumbs[0].copyTo(myFolder);
Copy link to clipboard
Copied
Ah that's useful to know, thank you Lumigraphics! I'm so new to this that even the most basic calls need a few pointers!
I managed to navigate the rotation problem by looking a bit more closely at the JS guide BitmapData functions and used:
var bm = new BitmapData(thumbs[i].spec);
var rotatedBM=bm.rotate(-90);
rotatedBM.exportTo(new File(exportFilePath));
Doubtless not the tidiest (or most efficient) way to do it but at least I've solved this particular problem (well I think I have!). I really do need to get my head into a book to understand this a lot more, completely clueless at the moment re functions for example.