Skip to main content
SunilRana_Gateway
Inspiring
January 24, 2011
Question

as increase DPI, image size is also increase in photoshop scripting ?

  • January 24, 2011
  • 2 replies
  • 3827 views

as  increase DPI, image size is also  increase in photoshop scripting can please tell me what  will the reason for that?

This topic has been closed for replies.

2 replies

JJMack
Community Expert
Community Expert
January 25, 2011

You can also change an images DPI setting without changing the number of pixels in an image the only thing that changes is to image print size because the image prints at a different pixel density.

JJMack
SunilRana_Gateway
Inspiring
January 25, 2011

Hi JJMACK,

                  I am using adobe  Flex with  Photoshop scripting . I am sending  Flex file  with parameter to generate .psd.Right now i am able to generate 72 DPI with proper image size while  I am generating  .psd with  250 DPI with Improper Size.

E.g

This is my  flex parameters

MgrPSAction.instance.FinishLayoutToPhotoshop(curFl , savedType ,TemplateConstant.TM_LEFT,getPSDImageName(objItem,TemplateConstant.TM_LEFT_RIGHT), objItem.LayoutTMLWidth,objItem.LayoutTMLHeight ,pageDPI,returnPhotoshopHandler,

true,setWidth , setHeight,formatQty); ----- Page DPI - > like 72 or 250 paasing  from here.

below is Scirpt ot resize

function openFileAndResize(xp,yp,wi,hi,imagepath)

{

var fileRef = new File(imagepath);

var curRefDoc = app.open(fileRef);

var curw = curRefDoc.width;

var curh = curRefDoc.height;

var resW;

var resH;

var scw = imgObj.wi/curw;

var sch = imgObj.hi/curh;

var scale ;

if(scw > sch)

scale = scw;

else

scale = sch;

resW = curw * scale;

resH = curh * scale;

if(imgObj.isAdjustImage == "true")

{

resW = resW * parseFloat (imgObj.scaleOrg);

resH = resH * parseFloat (imgObj.scaleOrg);

}

// Resize Image=======================================================

var idImgS = charIDToTypeID( "ImgS" );

var desc226 = new ActionDescriptor();

var idWdth = charIDToTypeID( "Wdth" );

var idPxl = charIDToTypeID( "#Pxl" );

desc226.putUnitDouble( idWdth, idPxl, resW);

var idHght = charIDToTypeID( "Hght" );

var idPxl = charIDToTypeID( "#Pxl" );

desc226.putUnitDouble( idHght, idPxl, resH );

var idIntr = charIDToTypeID( "Intr" );

var idIntp = charIDToTypeID( "Intp" );

var idBcbc = charIDToTypeID( "Bcbc" );

desc226.putEnumerated( idIntr, idIntp, idBcbc );

executeAction( idImgS, desc226, DialogModes.NO );

// Select Image=======================================================

var idsetd = charIDToTypeID( "setd" );

var desc263 = new ActionDescriptor();

var idnull = charIDToTypeID( "null" );

var ref138 = new ActionReference();

var idChnl = charIDToTypeID( "Chnl" );

var idfsel = charIDToTypeID( "fsel" );

ref138.putProperty( idChnl, idfsel );

desc263.putReference( idnull, ref138 );

var idT = charIDToTypeID( "T " );

var idOrdn = charIDToTypeID( "Ordn" );

var idAl = charIDToTypeID( "Al " );

desc263.putEnumerated( idT, idOrdn, idAl );

executeAction( idsetd, desc263, DialogModes.NO );

//Copy Image=======================================================

var idcopy = charIDToTypeID( "copy" );

executeAction( idcopy, undefined, DialogModes.NO );

app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

//Create Temp Layer for image adjustment =======================================================

//createApplication(wi,hi,dpi,"imagelayerdoc");

createApplication(wi,hi,dpi,layerAppName);

//var curDoc = getCurDoc('imagelayerdoc');

//get Active Temp Layer for image adjustment =======================================================

var curDoc = getCurDoc(layerAppName);

app.activeDocument = curDoc;

// Past Copy image in Temp Layer for image adjustment =======================================================

var idpast = charIDToTypeID( "past" );

var desc250 = new ActionDescriptor();

var idAntA = charIDToTypeID( "AntA" );

var idAnnt = charIDToTypeID( "Annt" );

var idAnno = charIDToTypeID( "Anno" );

desc250.putEnumerated( idAntA, idAnnt, idAnno );

executeAction( idpast, desc250, DialogModes.NO );

// HERE YOU NEED TO SET XY POSTION OF IMAGE

positionLayer(app.activeDocument.activeLayer,imgObj.moveX,imgObj.moveY);

cropImage();

}

Please reply if have answer...

Thanks

Muppet_Mark-QAl63s
Inspiring
January 24, 2011

You need to supply a resample method of 'none' with your resize command… What language are you using? Something like…

app.activeDocument.resizeImage(undefined, undefined, 600, ResampleMethod.NONE);

If you were using ESTK.

SunilRana_Gateway
Inspiring
January 25, 2011

Hi M Mark,

                  I am using adobe  Flex with  Photoshop scripting . I am sending  Flex file  with parameter to generate .psd.Right now i am able to generate 72 DPI with proper image size while  I am generating  .psd with  250 DPI with Improper Size.

E.g

This is my  flex parameters

MgrPSAction.instance.FinishLayoutToPhotoshop(curFl , savedType ,TemplateConstant.TM_LEFT,getPSDImageName(objItem,TemplateConstant.TM_LEFT_RIGHT), objItem.LayoutTMLWidth,objItem.LayoutTMLHeight ,pageDPI,returnPhotoshopHandler,

true,setWidth , setHeight,formatQty); ----- Page DPI - > like 72 or 250 paasing  from here.

below is Scirpt ot resize

function openFileAndResize(xp,yp,wi,hi,imagepath)

{

var fileRef = new File(imagepath);

var curRefDoc = app.open(fileRef);

var curw = curRefDoc.width;

var curh = curRefDoc.height;

var resW;

var resH;

var scw = imgObj.wi/curw;

var sch = imgObj.hi/curh;

var scale ;

if(scw > sch)

scale = scw;

else

scale = sch;

resW = curw * scale;

resH = curh * scale;

if(imgObj.isAdjustImage == "true")

{

resW = resW * parseFloat (imgObj.scaleOrg);

resH = resH * parseFloat (imgObj.scaleOrg);

}

// Resize Image=======================================================

var idImgS = charIDToTypeID( "ImgS" );

var desc226 = new ActionDescriptor();

var idWdth = charIDToTypeID( "Wdth" );

var idPxl = charIDToTypeID( "#Pxl" );

desc226.putUnitDouble( idWdth, idPxl, resW);

var idHght = charIDToTypeID( "Hght" );

var idPxl = charIDToTypeID( "#Pxl" );

desc226.putUnitDouble( idHght, idPxl, resH );

var idIntr = charIDToTypeID( "Intr" );

var idIntp = charIDToTypeID( "Intp" );

var idBcbc = charIDToTypeID( "Bcbc" );

desc226.putEnumerated( idIntr, idIntp, idBcbc );

executeAction( idImgS, desc226, DialogModes.NO );

// Select Image=======================================================

var idsetd = charIDToTypeID( "setd" );

var desc263 = new ActionDescriptor();

var idnull = charIDToTypeID( "null" );

var ref138 = new ActionReference();

var idChnl = charIDToTypeID( "Chnl" );

var idfsel = charIDToTypeID( "fsel" );

ref138.putProperty( idChnl, idfsel );

desc263.putReference( idnull, ref138 );

var idT = charIDToTypeID( "T " );

var idOrdn = charIDToTypeID( "Ordn" );

var idAl = charIDToTypeID( "Al " );

desc263.putEnumerated( idT, idOrdn, idAl );

executeAction( idsetd, desc263, DialogModes.NO );

//Copy Image=======================================================

var idcopy = charIDToTypeID( "copy" );

executeAction( idcopy, undefined, DialogModes.NO );

app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

//Create Temp Layer for image adjustment =======================================================

//createApplication(wi,hi,dpi,"imagelayerdoc");

createApplication(wi,hi,dpi,layerAppName);

//var curDoc = getCurDoc('imagelayerdoc');

//get Active Temp Layer for image adjustment =======================================================

var curDoc = getCurDoc(layerAppName);

app.activeDocument = curDoc;

// Past Copy image in Temp Layer for image adjustment =======================================================

var idpast = charIDToTypeID( "past" );

var desc250 = new ActionDescriptor();

var idAntA = charIDToTypeID( "AntA" );

var idAnnt = charIDToTypeID( "Annt" );

var idAnno = charIDToTypeID( "Anno" );

desc250.putEnumerated( idAntA, idAnnt, idAnno );

executeAction( idpast, desc250, DialogModes.NO );

// HERE YOU NEED TO SET XY POSTION OF IMAGE

positionLayer(app.activeDocument.activeLayer,imgObj.moveX,imgObj.moveY);

cropImage();

}

Please reply if have answer...

Thanks

Inspiring
January 25, 2011

SunilRana_Gateway, do you fully understand your code?

As Mark said you are resizing using the bicubic resample method. You need to change the resample method to none if you don't want to change the file size.

I would suggest that you replace the action manager(scriptlistener) image size code you have now with Marks DOM version.