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
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
See here for details on reading/changing the document raster settings.
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; }
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.
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;
};
North America
Europe, Middle East and Africa
Asia Pacific