jpeg dtc format problem

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

maeda

jpeg dtc format problem

Post by maeda »

Hi

tried to google the thing but no luck, folks from adobe ps forums pointed me here so..

I'm trying to find a batch solution for saving all progressive jpegs to baseline, with a bunch of photos i have 5% of them are in progressive format and my htpc(tv) chip can't decode.
Tried to find a tool that will (on large scale) identify jpeg dtc formats with no luck, only solution is to open in PS - 'save as' and change the format there, but when i tried to record action for batch in PS, it doesn't record change from progressive to baseline, only open-save as-close, so image remains in prog format.
Is there any way to script the thing, so it will remember to save as 'optimized' or some other solution i don't see?
Found also a script that will write down all jpg formats in a text file, but that works only with files already saved by PS, and most are not :/

tnx for any help

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mike Hale

jpeg dtc format problem

Post by Mike Hale »

Exiftool http://www.sno.phy.queensu.ca/~phil/exiftool/ can read Photoshop jpeg quality and jpeg format as well as the number of scans if it's Progressive. You could use that to narrow down the files to open and re-save in Photoshop.

But the script below should save the opened jpeg optimized with the quality setting of 8(changeable). It should overwrite the existing file.

Code: Select allvar docPath = app.activeDocument.fullName;
saveJPEG( app.activeDocument, docPath, 8 );
function saveJPEG( doc, saveFile, qty ) {
   var saveOptions = new JPEGSaveOptions( );
   saveOptions.embedColorProfile = true;
   saveOptions.formatOptions = FormatOptions.OPTIMIZEDBASELINE;
   saveOptions.matte = MatteType.NONE;
   saveOptions.quality = qty;
   doc.saveAs( saveFile, saveOptions, true );
};
Paul MR

jpeg dtc format problem

Post by Paul MR »

Maybe you could convert them in Bridge?
Please give this a try and see if it works.

Code: Select all#target bridge   
if( BridgeTalk.appName == "bridge" ) { 
removeMETADAT = new MenuElement("command", "Remove metadata",  "at the end of Tools");
}
removeMETADAT.onSelect = function () {
     removeMetadata();
     }

function removeMetadata(){
var Path =app.document.presentationPath;
var thumbs = app.document.getSelection("jpg");
if(!thumbs.length) return;
var JPGOUT = Folder(Path +"/JPGnoMeta");
if(!JPGOUT.exists) JPGOUT.create();

for(var i in thumbs){
         if(!thumbs.spec instanceof File) continue;
            var thumb = thumbs;
            var md = thumbs.synchronousMetadata;
            md.namespace = "http://ns.adobe.com/tiff/1.0/";
            var orientation = md.Orientation.replace(/(\w+)(\s+)(.)(\d+)(.)/,"$3$4");
            if(orientation == 'Normal') orientation =0;
            var bm = new BitmapData(thumbs.spec);
                    bm = bm.rotate(orientation);               
               var parts = thumbs.name.match(/(.*)\.([^\.]+)/);         
               bm.exportTo(new File(JPGOUT +"/"+ parts[1] +".jpg"),100);                  
        }
allDone();

function allDone(){
var win = new Window( 'dialog', 'All Done' );
g = win.graphics;
var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]);
g.backgroundColor = myBrush;
win.alignChildren="column";
win.g10 = win.add('group');
win.g10.orientation = "column";
win.title = win.g10.add('statictext',undefined,'Thats All Folks');
win.title.alignment="bottom";
var g = win.title.graphics;
g.font = ScriptUI.newFont("Georgia","BOLDITALIC",60);
win.g10.add('button',undefined,'Ok');
win.center();
win.show()
    }
}
To install:-
Start Bridge
Edit - Preferences - Startup Scripts
At the bottom click the "Reveal Button" this will open the folder where the script should be placed.
Restart Bridge and accept the new script.
Select a few JPGs to test and select the command from the bottom of the Tools Menu.
The new jpgs will be put in a new folder "JPGnoMeta" off the current folder.
maeda

jpeg dtc format problem

Post by maeda »

thank you, much appreciated

i'll test those scripts, or try to use exiftools to determine formats
Mike Hale

jpeg dtc format problem

Post by Mike Hale »

When I made my first post I must have skipped your last statement. I think Exiftool will only be able to sort the files by format if they were saved by Photoshop and you said most were not.

But if you want to give is a try here is the command string I used to test.

"C:\Program Files\Exiftool\exiftool.exe" "-directory<%d/jpeg/$<PhotoshopFormat>" C:\temp -ext jpg

That will search all the files in C:\temp with the jpg extension and sort them into subfolders by jpegFormat in C:\temp\jpeg\

In my test is sorted the files into two subfolders, Standard and Optimised, I guess there were not any saved as Progressive.

You may need to change the path to Exiftool if it is not installed in C:\Program Files\Exiftool\