• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

transparency photos - bridge

Explorer ,
Jun 09, 2013 Jun 09, 2013

Copy link to clipboard

Copied

Hi,

Is it possible to sort all pictures with transparency in Bridge CS6? I need to do this in my workflow.

If any fonction exist can i developpe a script with Javascript?

I'm not so bad in javascript but i have no ideas how to start?

Thanks!

TOPICS
Scripting

Views

4.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jun 09, 2013 Jun 09, 2013

Copy link to clipboard

Copied

You can't make custom sorts in Bridge with script… You can test files and change some properties to let you sort in other ways…

You could say label or rate them then sort based on that… or you could put the info in the metadata and use either sort or find…

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 09, 2013 Jun 09, 2013

Copy link to clipboard

Copied

Thanks you for your answer. I summarize:

if (isPhotoTransparent()){

     // then set label transparent

     // after sort by label_transparent

}

function isPhotoTransparent(){

     // open photo in Photoshop

     foreach xy pixel

     // test if color isTransparent

}

If any one could help me it would be really great! This question is often ask on the forum and if i find a solution i will post it here…

In advance thanks you for help!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jun 09, 2013 Jun 09, 2013

Copy link to clipboard

Copied

On my mac I have a script that generates a little preview of the file transparency when I select it… Helps me do this sort of thing…

What OS are you on…? I know how to get transparency on the mac without using photoshop not sure for windows thou…

If you have ExifTool installed then it should be possible on PC too… Paul would know how that is done…

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 09, 2013 Jun 09, 2013

Copy link to clipboard

Copied

Thanks you for your answer!

Its a good idea but i really need a way to do this automatically because i have 1000 photos to sort…

The goal its to save all photos with transparency with a script (export png) and the other in (export jpg).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jun 09, 2013 Jun 09, 2013

Copy link to clipboard

Copied

Yup you need script… You didn't say what OS thou… Bridge can make new *.jpegs without Photoshop but can't do the *pngs…

On the mac you could use SIPS to do that… Thats how I made my file previewer…

On either platform you should check out ExifTool it should be able to process the sort…

http://www.sno.phy.queensu.ca/~phil/exiftool/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 09, 2013 Jun 09, 2013

Copy link to clipboard

Copied

Hi,

Thanks you, sorry i miss this question!… I'm on mac os X 10.6.8 and i have the creative suite 6.

I'm reading about SIPS and it looks interresting:)

I say you if i find a way!

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jun 09, 2013 Jun 09, 2013

Copy link to clipboard

Copied

SIPS can do some basic image processing… What it doesn't lack is speed…

You may want to look at MDLS too… You can check out its man page in the terminal app…

Here is a snippet of how you may be able to construct a list of files that contain transparency… ( I only did a quick check )

#target bridge

var f = Folder.selectDialog( 'Select a Folder to search in?' );

var shellString = "mdfind -onlyin ";

shellString += "'" + f.fsName + "/'";

shellString += " 'kMDItemHasAlphaChannel == 1 ";

shellString += " && (kMDItemFSName == *.tif || kMDItemFSName == *.psd || kMDItemFSName == *.png)' > ";

shellString += "~/Desktop/StdOut.txt";

The text file this creates should be your files…? You can read this in Adobe's ExtendScript and process the files or you could pipe it to SIPS…

Im not too good at that stuff thou…

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jun 09, 2013 Jun 09, 2013

Copy link to clipboard

Copied

This is how I would check, but it would be slow if the file didn't have transparency....

var thumb = app.document.selections[0];

alert(hasTransparency(thumb));

function hasTransparency(thumb){

try{

    var image, bit, main, pix, row, x, y;

    image = thumb;

    bit = new BitmapData( image.spec );

    for ( y = 0; y < bit.height; y++ ) {

        for ( x = 0; x < bit.width; x++ ) {

            var Alpha =new Color( bit.getPixel32( x, y ) );

            if(Alpha.alpha != 255) return true;

        }

    }

return false;

}catch(e){alert(e + " - " + e.line);};

};

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jun 09, 2013 Jun 09, 2013

Copy link to clipboard

Copied

Paul, that is an option too but I would think it's somewhat slower…?

BTW can you see that yellow blob in the sky up there… Whats all that about… EOW?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jun 09, 2013 Jun 09, 2013

Copy link to clipboard

Copied

No yellow blob here, it's behind the clouds and had rain this morning (saves me watering the garden )

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jun 09, 2013 Jun 09, 2013

Copy link to clipboard

Copied

I've some scripts I should be working on… but the blob keeps attracting be outside and forcing me to have a beer instead…

It will be gone soon Im sure…

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jun 09, 2013 Jun 09, 2013

Copy link to clipboard

Copied

Mark, kMDItemHasAlphaChannel == 1 does that mean it has transparency or that it can support transparency, as I have looked at a simular method but on my test case some that didn't have transparency still had the flag saying it supported transpacency. Hope you can understand that after all those beers!

Yellow blob has come out and the boss has told me to go out and paint the fence!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 09, 2013 Jun 09, 2013

Copy link to clipboard

Copied

Thanks you the both solution work! It is really nice to help me!

i note the following points:

- the javascript file work with .png but not with .psd ?

- the javascript code work slower

So i propose do to that:

- developpe a solution who call a shell script -> sips --getProperty hasAlpha ref_srgb_sans.jpg

- find a way to sort with smart collection.

Thanks you

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jun 09, 2013 Jun 09, 2013

Copy link to clipboard

Copied

Have a tinker with something like this… I thinks its working with a very basic test…?

#target bridge

processFolder();

function processFolder() {

 

          var i, coll, doc, has, hasNot, thum;

 

          doc = app.document.thumbnail.spec;

 

          hasTransparency( doc, true );

 

          has = stdoutToArray();

 

          $.sleep( 500 );

 

          //$.writeln( has );

 

          coll = app.createCollection( 'Has Alpha' );

 

          for ( i = 0; i < has.length; i++ ) {

 

                    thum = new Thumbnail( File( has ) );

 

                    app.addCollectionMember( coll, thum )

 

 

          };

 

          hasTransparency( doc, false );

 

          hasNot = stdoutToArray();

 

          $.sleep( 500 );

 

          //$.writeln( hasNot );

 

          coll = app.createCollection( 'No Alpha' );

 

          for ( i = 0; i < hasNot.length; i++ ) {

 

                    thum = new Thumbnail( File( hasNot ) );

 

                    app.addCollectionMember( coll, thum )

 

 

          };

 

};

function hasTransparency( doc, trans ) {

          

          var shellString = "mdfind -onlyin ";

 

          shellString += "'" + doc.fsName + "/'";

 

          if ( trans ) {

 

                    shellString += " 'kMDItemHasAlphaChannel == 1 ";

 

          } else {

 

                    shellString += " 'kMDItemHasAlphaChannel == 0 ";

 

          };

          shellString += " && (kMDItemFSName == *.tif || kMDItemFSName == *.psd || kMDItemFSName == *.png)' > ";

 

          shellString += "~/Desktop/StdOut.txt";

          

          var sh = app.system( shellString );

          return( sh );

};

function stdoutToArray() {

 

          var filePath = File( Folder.desktop + '/StdOut.txt' );

 

          var fileList = Array();

 

          filePath.open( 'r' );

 

          while ( !filePath.eof ) {

 

                    fileList.push( filePath.readln() );

 

          };

          filePath.close();

 

          filePath.remove();

 

          return fileList;

 

};

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jun 09, 2013 Jun 09, 2013

Copy link to clipboard

Copied

I think this is the latest version of my little previewer…?

The one loaded is a binary and I can't remember when I last changed it…

I did it just for some fun… Was going to add some prefs but never got around to it…

Oh yellow… blob got to go…

#target bridge

// One second window ( with yuk green matte )

function transSelectWindow() {

          var png, prfs, win;

          prfs = File( Folder.desktop + 'muppetspreview.txt' );

 

          //if ( ! prfs.exists ) { prefsWindow( prfs ) };

 

          png = File( Folder.temp + '/muppetspreview.png' );

          if ( png.exists ) {

                    win = new Window( 'palette' );

                    win.text = 'Transparancy Preview';

 

                    win.margins = 0;

                    win.graphics.backgroundColor = win.graphics.newBrush

                              ( win.graphics.BrushType.SOLID_COLOR,[0,1,0] );

                    win.add( 'image', undefined, png );

                    win.center();

                    win.show();

                    $.sleep( 1000 );

                    win.close();

 

                    png.remove();

          };

};

// A window for the script prefs ( NOT done yet )

function prefsWindow( file ) {

 

          var matte, win;

 

          win = new Window( 'palette' );

          win.text = 'Transparancy Preview Prefs:';

 

          win.center();

          win.show();

          win.close();

};

// Use system to get PNG of file

function sipsGetPNG( file, size ) {

          var shell = 'sips -Z ' + size + ' -s format png ';

          shell += file.fsName.replace( /\s/g,'\\ ' );

          shell += ' --out ';

          shell += Folder.temp.fsName.replace( /\s/g,'\\ ' );

          shell += '/muppetspreview.png';

          app.system( shell );

};

// Define Bridge event handlers

onSelectionChange = function( event ) {

 

          var h, w, m, thumb;

          if ( event.object instanceof Document && event.type == 'selectionsChanged' ) {

                    if ( event.object.selectionsLength == 1 ) {

 

                              thumb = event.object.selections[0];

 

                              if ( /\.(ai||pdf||png||psd||tif+)$/i.test( thumb.name ) ) {

 

                                        h = thumb.core.quickMetadata.height;

 

                                        w = thumb.core.quickMetadata.width;

 

                                        m = Math.max( h, w );

 

                                        if ( m > 800 ) {

                                                  sipsGetPNG( thumb.spec, 800 );

 

                                        } else {

 

                                                  sipsGetPNG( thumb.spec, m );

 

                                        };

                                        transSelectWindow();

 

                              };

                    };

                    return { handled: true };

          };

};

// Register event handler ( on mac only )

if ( /Macintosh/i.test( $.os ) ) {

 

          app.eventHandlers.push( { handler: onSelectionChange  } );

} else {

          alert( 'Sorry it\'s a mac thing…' );

};

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jun 09, 2013 Jun 09, 2013

Copy link to clipboard

Copied

The mystery blob thing captured…

IMG_0010.JPG

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jun 09, 2013 Jun 09, 2013

Copy link to clipboard

Copied

Its aliens me thinks… n their making my skin go pink…?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jun 09, 2013 Jun 09, 2013

Copy link to clipboard

Copied

Hi Mark , I still think you are not getting the right information. I believe you are only getting "If it can support transparancy" not if it has transparency.

I have come up with this for PNGs and it is much faster that checking each pixel....

var thumb = app.document.selections[0];

var bm1 = new BitmapData( thumb.spec );

var tempFile = File(Folder.temp + "/bmtest.jpg");

bm1.exportTo(tempFile,100);

var bm2 = new BitmapData(new Thumbnail(tempFile).spec);

$.writeln(bm1.checksum);

$.writeln(bm2.checksum);

bm1.dispose();

bm2.dispose();

tempFile.remove();

The checksums should be the same if there is no transparancy.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jun 10, 2013 Jun 10, 2013

Copy link to clipboard

Copied

Paul, there is a trasparency property in Bridge this is just a boolean if the file supports it… On my mac the script works fine…

The HasAlphaChannel in the file metadata is 1 if any pixel or greater is not 100% solid colour…

I only ran a test with about 40 or so files but the split to 2 collections was correct here…

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jun 10, 2013 Jun 10, 2013

Copy link to clipboard

Copied

Mark, I knew there had to be a reason why people used a Mac, now I know why! I don't think this is available on a PC, the only thing I could find was the colorMode with a PNG of 4 or 6 that supports transparency but that didn't decide if it had transparency.

1 up for the Mac

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jun 10, 2013 Jun 10, 2013

Copy link to clipboard

Copied

sips -g hasAlpha /Users/marklarsen/Desktop/Untitled-1.psd

Should also do the trick… But you would need to filter the file types first…

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 13, 2013 Jun 13, 2013

Copy link to clipboard

Copied

Hi,

Thanks for this scripts! It works fine on my Mac

I have another question. How do you develop for Bridge? For example, if developpe in Java I use NetBeans and the javadoc to know the existing functions. With Adobe, the extendedToolScript does not propose the autocompletion. And SDK provided not the list of all  functions. I have only codes of example.

I try to know how to do a smartCollection…

Thanks you!

Bastien

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 13, 2013 Jun 13, 2013

Copy link to clipboard

Copied

Hi all,  I wrote this! But it does'nt work yet! I'm bad in Javascript for Bridge

#target bridge

var coll_without_profil;

var currentPath = app.document.thumbnail.spec;

// list of condition

searchCondictionList = Array();

var searchCondition = new SearchCondition('colorMode', 'equals', 'RGB');

searchCondictionList.push(searchCondition);

var scopeSpecifiers = Array();

var scopeSpecifier = new Scope('r');

scopeSpecifiers.push(scopeSpecifier);

var searchSpec = new SearchSpecification(searchCondictionList, 'and', 10, 'ascending', 'test', scopeSpecifiers);

createSmartCollection ();

function createSmartCollection(){

    coll_without_profil = app.createSmartCollection( 'documents_sans_profil', currentPath,  searchSpec);

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jun 13, 2013 Jun 13, 2013

Copy link to clipboard

Copied

You will NOT be able to create smart collections with Bridge using the ExtendScript DOM… Not all features cross over to scripting… There is much in the doc's that does NOT apply to script but is for developers…

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines