10 Replies Latest reply: Jun 1, 2012 7:38 PM by Paulo Skylar RSS

    How can I determine if a png, created in photoshop, is interlaced?

    szelma

      How can I determine if a png, created in photoshop, is interlaced?

      I have about 10 png files I need to check. Sure I could just re-save them for web and make them all interlaced,

      but I don't want to lose image quality by going through this process again if it is unnecesary (because they are already interlaced).

       

      Thank you.

        • 1. Re: How can I determine if a png, created in photoshop, is interlaced?
          Curt Y Community Member

          Couple of facts about interlaced and non-interlaced.

           

          Interlaced is actually the displaying method of an image. There are 2 types to display modes, 1 is interlaced and other is non-interlaced or progressive scan mode. In progressive scan mode the display displays all the horizontal lines at a time from top to bottom and in non interlaced it display half horizontal lines once and remaining half on next time.

          The image you have saved as interlaced means that display will scan it as interlaced input and display it in interlaced mode. The display quality of no-interlaced is always better than interlaced.

           

          Choosing Interlaced means that the whole image is displayed from the get-go, starting at low quality and gradually improving as more data is downloaded to the browser, sort of like coming into focus.

          Obviously the speed of the host server pushing the data and the bandwidth of the users connection has a direct bearing on the time it takes to render the web page and graphics.

           

          So if the image appears all at once and the resoultion increases in is interlaced.  If it is displayed in stages from top to bottom it is non-interlaced.

          • 2. Re: How can I determine if a png, created in photoshop, is interlaced?
            szelma Community Member

            Thanks, Curt.

            "So if the image appears all at once and the resoultion increases it is interlaced.  If it is displayed in stages from top to bottom it is non-interlaced."

             

            What is the fastest and easist way to analyze a group of png files (that live on a hard drive of a desktop computer) to determin if they are interlaced on non-interlaced? How can I quickly analyze the files and/or use CS6 to analyze the files?

             

            Thanks!

            • 3. Re: How can I determine if a png, created in photoshop, is interlaced?
              Curt Y Community Member

              Don't know about that, or if it is even possible.  If they are big files and open slowly enough I guess you might be able to tell. 

               

              I just did a test with a 500k jpeg and converted to png both types.  Came out 8 meg but could not tell when loaded to PS. 

              • 4. Re: How can I determine if a png, created in photoshop, is interlaced?
                Paul Riggott Community Member

                You could use a script, the following should create a text file on the desktop with the results, the last number is the Interlace

                0 Non Interlace 1 Interlace

                 

                 

                You can copy and paste the script into ExtendScript Toolkit and run it from there....

                 

                
                

                File.prototype.readByte = function() {
                   return this.read(1).charCodeAt(0);
                };
                File.prototype.readShort = function(ET) {
                   var self = this;
                   var b1 = this.readByte();
                   var b2 = this.readByte();
                   if(ET == "LE"){
                      return (b2 << 8) + b1;
                   }else{
                      return (b1 << 8) + b2;
                   }
                };
                File.prototype.readLong = function(ET) {
                   var self = this;
                   var s1 = self.readShort(ET);
                   var s2 = self.readShort(ET);
                   if(ET == "LE"){
                      return (s2 << 16) + s1;
                   }else{
                      return (s1 << 16) + s2;
                   }
                };

                var folder = Folder.selectDialog( "Please select input folder");
                var results = File(Folder.desktop + "/PNG Info.txt");
                results.open('w');
                results.writeln("FileName,Width,Height,BitDepth,ColourType,CompressionType,FilterType,InterlaceType");
                var PNGS = folder.getFiles("*.png");
                var Info = [];
                for (var a in PNGS){
                var file = File(PNGS[a]);
                file.encoding = 'BINARY';
                file.open('r');
                file.seek(16,0);
                var Width = file.readLong();
                var Height = file.readLong();
                var BitDepth = file.readByte();
                var ColourType = file.readByte();
                var CompressionType = file.readByte();
                var FilterType = file.readByte();
                var InterlaceType = file.readByte();
                file.close();
                Info.push([[decodeURI(file.name)],[Width],[Height],[BitDepth],[ColourType],[CompressionType],[FilterType],[InterlaceType]]);
                }
                for(var z in Info){
                results.writeln(Info[z].toString());
                }
                results.close();

                 

                • 5. Re: How can I determine if a png, created in photoshop, is interlaced?
                  Paulo Skylar Community Member

                  There are a number of statements in this thread that need a bit of clarifying for other readers.

                   

                  "but I don't want to lose image quality by going through this process again if it is unnecesary (because they are already interlaced)."  

                  Why do you think that opening and resaving a png file as interlaced will loose image quality? The compression used in png files is not lossy as it is in jpeg files. So just resave the files.

                   

                   

                  "Interlaced is actually the displaying method of an image.

                  Interlace, in the context of an attribute of png files, is not a method of displaying an image. It is a process of transmitting an image from a server to a client so that when it is displayed it approaches its final quality quickly.

                  This had been an issue when many Internet users were on dial-up, that is, slow connections. With today's faster connections you need a good reason to choose interlacing as it increases file size.


                   

                  "There are 2 types to display modes, 1 is interlaced and other is non-interlaced or progressive scan mode."

                  Actually, the terminology used for interlacing in png files is that an interlaced image is transmitted progressively, or is progressive in time.

                   

                  "In progressive scan mode the display displays all the horizontal lines at a time from top to bottom and in non interlaced it display half horizontal lines once and remaining half on next time."  

                  This comment more closely describes classic TV scanning in the monitor and has nothing to do with png interlace. I say closely describes because it is technically not accurate even for TV.  In png interlacing the data is transmitted in a more complicated way that is not even one dimensional and takes numerous passes. Furthermore, the data transmitted is not necessarily the data displayed as the viewer or browser may interpolate the transmitted data to provide the display data (during the transition period).

                   

                   

                  The image you have saved as interlaced means that display will scan it as interlaced input and display it in interlaced mode. The display quality of no-interlaced is always better than interlaced."

                  NO!  The png interlacing does not control the display of an image it controls the transmission of the image. Your display, lets say is an LCD monitor with a progressive (line sequential) scan operation (this is standard), is not going to somehow show a png image in a scan  interlaced mode while the rest of the display is line sequential. The comment about display quality is also something more appropriately applied to early TV .  Interlaced and non interlaced png files have the same image quality when static. They only appear different when the display is transitioning from no image to full image.

                   

                  Paulo

                  • 6. Re: How can I determine if a png, created in photoshop, is interlaced?
                    Curt Y Community Member

                    Paulo Skylar wrote:

                     

                    There are a number of statements in this thread that need a bit of clarifying for other readers.

                     

                     

                    The png interlacing does not control the display of an image it controls the transmission of the image.

                     

                    The statements you are quoting I got from the internet, and we all know just becasue it is there in print does not make it correct. 

                     

                    However, I think you are mixing two concepts.  If one takes a TIFF image and converts it to a PNG there is a choice of using interlaced or non-interlaced to save.  You just have an image.  What you are talking about is transmitting the data as interlaced or non-interlaced.  And indeed there is a difference.

                     

                    But the OP already had his PNG images on the HD and just wanted to know if they were interlaced or not when he saved them. 

                     

                    One of the advantages of the forum one can get different views and the OP can decide what he wants to believe.

                    • 7. Re: How can I determine if a png, created in photoshop, is interlaced?
                      Paulo Skylar Community Member

                      With regard to image formats, the term interlace only refers to one thing - the way it is transmitted. When chosen, the desired method of transmission is thus encoded in the file. It has no effect on image quality (except transiently), it has no effect on how the monitor operates, but it does have an effect on file size, increasing the file size for interlaced images.

                       

                      Your comments refer to the two principle ways displays scan or write the image on the screen. That interlacing is strictly a harware issue and has nothing to do with file formats.  An interlaced png file can be equally well displayed on monitors that operate with interlaced or non interlaced scanning. Likewise, a non interlaced png file can be equally well displayed on monitors having interlaced or non interlaced scanning.

                       

                      This is not a matter of believeing, it is a matter of what interlace means for png files and what interlace means for monitor operation. They are very well defined concepts.

                       

                      Paulo

                      • 8. Re: How can I determine if a png, created in photoshop, is interlaced?
                        szelma Community Member

                        First off, thank you all for discussing this matter. I really appreciate your contributions.

                         

                        Paul, thanks for the ExtendScript Toolkit! I'm not clear about how to use the script. Could you point me to some directions?

                         

                        Regarding Paulo's comment:

                         

                        "Why do you think that opening and resaving a png file as interlaced will loose image quality? The compression used in png files is not lossy as it is in jpeg files. So just resave the files."

                         

                        I did some tests, and the file always changes size. I take the already optimized png,  "save as" or "save for web"  and in both instances the file size of the png becomes smaller. Are you saying that this doesn't impact image quality or resolution?

                         

                        It would be ideal to open up a png file in photoshop and be able to find out the details of the image file, is it interlaced? transparent? etc. It's a clunky process to have to reopen and resave files just to be sure a png is formatted a particular way. however, we can't have everything, can we! I'll try the ExtendScript Toolkit.

                         

                        My take away is that with photoshop there's no other option but to resave the files in question. I wouldn't care so much if this was just for a few web graphics, but i have to test pgs for a web app that has hundreds of images. And again, because the image size is changing when I resave the png, it leaves me with some uncertainty as to what is happening to the file.

                        • 9. Re: How can I determine if a png, created in photoshop, is interlaced?
                          Paul Riggott Community Member

                          ExtendScript Toolkit gets installed at the same time as Photoshop.

                          It can normally be found:-
                          PC: "C:\Program Files (x86)\Adobe\Adobe Utilities - CS5\ExtendScript Toolkit CS5\ExtendScript Toolkit.exe"

                          MAC: <hard drive>/Applications/Utilities/Adobe Utilities

                          Just paste the code into a window and run the code, it will then prompt for you to select the folder where the PNG files are. A text file will then be created on the desktop.

                          You could just run the script from Photoshop if you wish by saving the script as Whatevernameyoulike.jsx into the application Presets/Scripts folder. Restart Photoshop so that it picks up the new script, then File - Scripts - select the script.
                          You could rename the text file to .csv then it would load straight into Excel etc.

                          • 10. Re: How can I determine if a png, created in photoshop, is interlaced?
                            Paulo Skylar Community Member

                            szelma wrote:

                            ....   I did some tests, and the file always changes size. I take the already optimized png,  "save as" or "save for web"  and in both instances the file size of the png becomes smaller. Are you saying that this doesn't impact image quality or resolution?

                             

                            Not sure how you are doing your tests or how your are determining your file sizes, but something is amiss. If you open an interlaced png file and save it again as an interlaced png file the file size should remain the same. You can check the results by loading both images into the same photoshop document and comparing them, say by changing the blend mode of one to subtract and you will see black - every pixel value in image 1 is  the same as in image two.  The histogram will contain only a spike at zero. And just for fun compare in the same way either of those images with a non interlaced version of the image.

                             

                            If your starting image is interlaced and you save it as non interlaced then the image size will decrease slightly.

                             

                            So the recommended approach is to simply batch convert all your png files to interlaced png files and you have what you need with no loss of quality. Don't take my word for it, try it on some test files and compare the results.

                             

                            Paulo