11 Replies Latest reply: Mar 8, 2013 1:02 AM by Toto RoToTO RSS

    outWidth and outHeight dont work for AIImageOptSuite

    Hitz_M Community Member

      Hello,

       

      While using the AIImageOptSuite.MakePNG24 and AIImageOptSuite.AsJPEG, the width and height of the generated image is not the value set in

      AIImageOptJPEGParams.outWidth and AIImageOptJPEGParams.outHeight.

       

      My code is:

       

      AIImageOptJPEGParams jpegParams;

      jpegParams.resolution = 200;

      jpegParams.blurAmount = 0;

      jpegParams.quality = 100;

      jpegParams.kind = AIImageOptJPEGStandard;

      jpegParams.scans = 1;

      jpegParams.outAlpha =

      false;

      jpegParams.outHeight = 1200;

      jpegParams.outHeight = 1200;

       

      //Generates the jpg for a layer specified by layerArt

      result= sAIImage->AsJPEG(layerArt, dstfilter, jpegParams);

       

       

       

      The size of the output image is random and depends on the contents of the layer.

      I am using CS3 SDK.

       

      Thanks,

      Hitesh

       

        • 1. Re: outWidth and outHeight dont work for AIImageOptSuite
          Hitz_M Community Member

          Hello,

           

          Anyone has any information on this?

          Please help.

           

          Thanks,

          Hitesh

          • 2. Re: outWidth and outHeight dont work for AIImageOptSuite
            btemp Community Member

            What about the other options you're setting? What is "result"?

             

            In the code you posted, you set jpegParams.outHeight twice.

            • 3. Re: outWidth and outHeight dont work for AIImageOptSuite
              Hitz_M Community Member

              Hello,

               

              Sorry for the late response. but this has come back to haunt me again.

              THe complete code is:

              //Get the layer art

              AILayerHandle Firstlayer = NULL;

              AIArtHandle rasterOut = NULL;

              sAILayerSuite->GetFirstLayer(&Firstlayer);

              sAIArt->GetFirstArtOfLayer( Firstlayer, &rasterOut);

               

               

              //Creating the data filter

              AIDataFilter* dstfilter = NULL;

              AIDataFilter* filter;

               

               

              if (!result)

              result = sAIDataFilter->NewFileDataFilter(filePath,

              "write", 'ART5', 'TEXT', &filter);

               

              if (!result)

              {

              result = sAIDataFilter->LinkDataFilter(dstfilter, filter);

              dstfilter = filter;

              }

               

              if (!result)

              {

              result = sAIDataFilter->NewBufferDataFilter(32*1024, &filter);

               

              }

               

              if (!result)

              {

              result = sAIDataFilter->LinkDataFilter(dstfilter, filter);

              dstfilter = filter;

              }

               

               

              //Generate JPEG

              AIImageOptJPEGParams jpegParams;

              jpegParams.resolution = 300;

              jpegParams.blurAmount = 0;

              jpegParams.quality = 100;

              jpegParams.kind = AIImageOptJPEGStandard;

              jpegParams.scans = 1;

              jpegParams.outAlpha =

              false;

              jpegParams.outHeight = 1200;

              jpegParams.outWidth = 1200;

               

              result= sAIImage->AsJPEG(layerArt, dstfilter, jpegParams);

               

              while

               

              (dstfilter)

              {

                   sAIDataFilter->UnlinkDataFilter(dstfilter, &dstfilter);

              }

               

               

               

              result is always kNoErr. The JPEG image is generated with resolution 300 but the width and height of the generated image is not 1200.

               

              Thanks,

              Hitesh

              • 4. Re: outWidth and outHeight dont work for AIImageOptSuite
                btemp Community Member

                Have you tried setting a different resolution? Does that affect the results?

                • 5. Re: outWidth and outHeight dont work for AIImageOptSuite
                  A. Patterson Community Member

                  Another thing to try is screwing with the Document Raster settings, see if that affects things or not. If they do, there might be something else we can try.

                  • 6. Re: outWidth and outHeight dont work for AIImageOptSuite
                    Hitz_M Community Member

                    Changed resolution to 150 and 200, the dimension of the file change but againg they are not 1200.

                    It seems that outWidth and outHeight are ignored.

                     

                    How to change the document raster settings?

                    • 7. Re: outWidth and outHeight dont work for AIImageOptSuite
                      Wayne Constable-AEjbzi

                      See here for details on reading/changing the document raster settings.

                      • 8. Re: outWidth and outHeight dont work for AIImageOptSuite
                        Hitz_M Community Member

                        Change the color model and resolution through Effect->Document Raster Effect Settings that didnot work.

                        I also change the artboard size in File->Document Setup but this also didnot work.

                        I moved to CS4 but still the same problem.

                        Is there any other way to get this done...export action/save for web action?

                         

                        I had once tried the following solution to get the ArtHandle of the layer, is there something that can be done here to set the size?

                         

                        AIErr GetLayerRaster(AILayerHandle layer, AIArtHandle &rasterOut)

                        {

                        AIErr error = kNoErr;

                        AIArtSet artSet = NULL;

                         

                        // Specify the type of art.

                        AIArtSpec specs[1] = {{kAnyArt,0,0}};

                         

                        // Create the art set.

                        error = artSetSuite->NewArtSet(&artSet);

                         

                         

                        // Populate the art set.

                        error = artSetSuite->LayerArtSet(layer, artSet);

                         

                        //Create raster settings

                        AIRasterizeSettings rasterSettings;

                        rasterSettings.type = kRasterizeRGB;

                         

                        //Compute bounds

                        AIRealRect bounds;

                        error = sAIRasterize->ComputeArtBounds(artSet, &bounds,

                        false);

                         

                         

                        //Create raster

                        error = sAIRasterize->Rasterize( artSet, &rasterSettings, &bounds, kPlaceAboveAll, 0, &rasterOut, MyRasterizeProc);

                         

                         

                        artSetSuite->DisposeArtSet(&artSet);

                        artSet = NULL;

                         

                        return error;

                        }

                        • 9. Re: outWidth and outHeight dont work for AIImageOptSuite
                          Harsh V Sharma Community Member

                          Hi Hitesh,

                           

                          I am working on the same thing as you were...

                           

                           

                          Can you please tell me that what are

                           

                          •      result= sAIImage->AsJPEG(layerArt, dstfilter, jpegParams);

                           

                          in your code.

                           

                          Thanks

                          • 10. Re: outWidth and outHeight dont work for AIImageOptSuite
                            ranvis.

                            I experienced the same problem of AIImageOptSuite.

                            But stepping through the code I suddenly noticed that outWidth and outHeight was changed after the call.

                            So outWidth and outHeight are "out parameters" that callee sets, while outAlpha seems not.

                             

                            If you want 1200px width image, you may have to calc the resolution like (1200.0 / art_width * 72), or keep the resolution 72 and scale the Art itself in advance.

                            • 11. Re: outWidth and outHeight dont work for AIImageOptSuite
                              Toto RoToTO Community Member

                              just take a look at AIImageOptParams struct defined in AIImageOptimization.h and you will notice outWidth and outHeight are out parameters. What outAlpha is not.

                               

                              /** PNG parameters for image optimization. See \c #AIImageOptSuite and

                              additional parameters in \c #AIImageOptPNGParams2. */

                              struct AIImageOptPNGParams {

                              /** When true, the input image is interlaced. */

                              AIBool8 interlaced;

                              /** The number of colors in the input image, in the range [2..255]. */

                              ai::int32 numberOfColors;

                              /** The transparency index of the input image, in the range [0..numberOfColors-1]. */

                              ai::int32 transparentIndex;

                               

                              /** The image resolution, in pixels per inch, of the input image.   */

                              AIFloat resolution;

                              /** When true, include an alpha channel in the output image. */

                              AIBool8 outAlpha;

                              /**  The width in pixels of the output image. */

                              ai::int32 outWidth;

                              /** The height in pixels of the output image. */

                                        ai::int32 outHeight;

                              };