7 Replies Latest reply on Sep 2, 2010 1:41 AM by magic3000_chris

    Image Conversion

    magic3000_chris

      Hi.....

       

      I am using CS3 with Windows XP.

       

      In my inDesign file, it has some image from TIFF file, e.g. imageA.tif . However, the image was resized and scaled in inDesign.

       

      When I try to export and convert the TIFF file to JPEG file using file export, then I found the resolution is changed because of the image is resized and scaled in inDesign.

       

      For example, the original TIFF file is 100 X 100, output JPEG is 80 X 80.

      Is it possible to keep the resolustion as original?

       

      The TIFF file is existed and accessable in the system, I totally got no idea how can i convert the TIFF to JPG.

       

      Thanks guys. I think some people can help me on it, my head almost blow off... >.<

       

      cheers

      Chris

        • 1. Re: Image Conversion
          [Jongware] Most Valuable Participant

          It's not possible to use InDesign to convert images as-they-are to another format -- it's kind of like using a battleship to, erm, do something not quite related to battleships. Or something.

           

          Why not use a dedicated graphics conversion program?

          • 2. Re: Image Conversion
            Andreas Jansson Level 2

            As you probably know, you can export images as JPEG from InDesign, using the exportFile method like:

             

            newImage.exportFile(format=ExportFormat.JPG , to=jpgFileName);

             

            You would probably have to know what size you want the new image to be. That might be your real issue here, but I'll post this as well:

             

            I had some problems with getting only a part of the image as the exported result. Perhaps you will run into the same problem.

             

            I found this comment in my code:

                // In CS4 latest desktop version the size of the container does not seem to matter for the export size taking place in the main code.
                // However, in CS3 and in CS4 Server there seems to be a bug, not exporting the whole image, but only a part of it. A bug unless there is some sort of setting, that differs between the versions. Setting the image container to an area large anough (or fitFrameToContent) seems to work well.

             

            I ended up with placing the full image on a new place, making sure that the image content is fitted within its container, exporting it, and then removing it from the document.

             

             

            var newImage = placeImage(newDoc, fullPathToOrigImage, pixelHeight);
            newImage.exportFile(format=ExportFormat.JPG , to=jpgFileName);
            
            function placeImage(doc, fileRef){ //, desiredHeight){
                var desiredHeight = '100mm';
                var desiredWidth = '100mm';
                imageRect = doc.pages[0].rectangles.add(doc.layers.item(-1), undefined, undefined, {geometricBounds:[0, 0, desiredHeight, desiredWidth], strokeWeight:0, strokeColor:doc.swatches.item('None')});
                var placedImage = imageRect.place(File(fileRef), false)[0];
                // The following line is vital for (some) larger images, since they will be
                // cropped in CS3 and CS4 Server. (Probable bug). Works without setting the
                // containter size in CS4 desktop with latest version update.
                imageRect.fit(FitOptions.frameToContent);
                
                return placedImage;
            }
            

             

            (In vital code one would also have to make sure that the layer is not locked, or even create a new layer...)

             

            I hope this can be of some help.

             

            Best regards,

            Andreas

            1 person found this helpful
            • 3. Re: Image Conversion
              Marijan Tompa [tomaxxi] Level 4

              Exporting JPEG from InDesign is really bad idea. Quality is not maintained as original file.

               

              --

              tomaxxi

              http://indisnip.wordpress.com/

              • 4. Re: Image Conversion
                Andreas Jansson Level 2

                Nevertheless: it's there, and it's possible to use it. For creating jpeg representations out of any file format supported by InDesign exportFile is a very simple solution. Quality is not always top prio when it comes to creating a jpeg. Just to be able to show all images on a web page might be good enough.

                • 5. Re: Image Conversion
                  magic3000_chris Level 1

                  Thanks Andreas!!!

                   

                  You gave me a huge idea to make it happen! Here is my sample coding.....

                   

                  function myExportPages(myDocument) {
                      var test = myDocument.rectangles.add();
                      test.place(File("/D/InDesign/Output/testingABC.tif"), false);
                      test.fit(FitOptions.frameToContent);
                      
                      app.jpegExportPreferences.resolution = test.images[0].actualPpi[0];
                      app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.HIGH;
                      app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.EXPORT_ALL;
                      
                      test.exportFile(ExportFormat.JPG, File("/D/InDesign/Output/OK.jpg"), false);
                      test.remove();
                  }
                  

                   


                  I know its a bit dirty by adding and removing the image inside the document. But it can keep the best resolution and size. The "app.jpegExportPreferences.resolution = test.images[0].actualPpi[0];" is the key point to keep the resolution.

                   

                  Thank you very much to everyone helping!!! This place is awesome!!

                  • 6. Re: Image Conversion
                    Andreas Jansson Level 2

                    I'm glad I was able to help you!

                     

                    About the ppi, just make sure to assign a default value if you are dealing  with vector graphics, such as illustrator ai files, vector EPS images and likewise. Vector graphics has no ppi, since they can be set to any size, and that's why you would have to decide the ppi or size by yourself when it comes to exporting that kind of files to jpeg.

                     

                    Best regards,

                    Andreas

                    • 7. Re: Image Conversion
                      magic3000_chris Level 1

                      OIC......

                       

                      Thanks. That's easy then.

                       

                      You give me a pre-exception handling. LOL

                       

                       

                      Cheers

                      Chris