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

outWidth and outHeight dont work for AIImageOptSuite

Explorer ,
Mar 25, 2010 Mar 25, 2010

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

TOPICS
SDK
3.6K
Translate
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
Adobe
Explorer ,
May 05, 2010 May 05, 2010

Hello,

Anyone has any information on this?

Please help.

Thanks,

Hitesh

Translate
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
Guest
May 05, 2010 May 05, 2010

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

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

Translate
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 ,
Jul 23, 2010 Jul 23, 2010

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

Translate
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
Guest
Jul 23, 2010 Jul 23, 2010

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

Translate
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
Guide ,
Jul 23, 2010 Jul 23, 2010

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.

Translate
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 ,
Jul 26, 2010 Jul 26, 2010

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?

Translate
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 ,
Jul 26, 2010 Jul 26, 2010

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

Translate
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 ,
Jul 27, 2010 Jul 27, 2010

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;

}

Translate
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
New Here ,
Mar 01, 2013 Mar 01, 2013

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.

Translate
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
Enthusiast ,
Mar 08, 2013 Mar 08, 2013
LATEST

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;

};

Translate
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
Guest
Nov 18, 2012 Nov 18, 2012

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

Translate
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