Skip to main content
rikinp27770370
Participating Frequently
March 22, 2019
Question

Need reference code to use Scripting API for java to resize images

  • March 22, 2019
  • 2 replies
  • 4272 views

Hello,

As per my initially discussion with adobe team on phone, We have raised our query with adobe team in below portal and link.

Need to resize TIFF with transparency

After a week of time, they come back with answer but shared solution was not able to clear our query. Now they have asked us to post our query in this portal. In short we are moving one forum to other forum of adobe to clear our query.

Here is our question.

We need sample java script or API to resize TIFF (Multi layer - Transparency )  images using java code. We have checked below links but we can't find the way how to use this java script to resize images using java code. https://www.adobe.com/devnet/photoshop/scripting.html

Hoping for a quick response.

Thanks

Rikin

This topic has been closed for replies.

2 replies

JJMack
Community Expert
Community Expert
March 22, 2019

The latest Adobe documentation is downloadable from this link Adobe Photoshop Scripting  the link you post it shows in photoshop-cc-javascript-ref-2019.pdf page 95

and on page 96 the example code

Only width and height is required.... The ducDoc was opened from a tif file the may be an error in the code the statement  in there I believe should be

duckDoc.resizeImage(flowerDoc.width, flowerDoc.height);

not

duckDoc.resize(flowerDoc.width, flowerDoc.height);

for Resize seems to be for a layer and layers within a layer set and is a relative resize and other thinhs like selections

The resize in the example code may also distort the image for I see no logic to preserve the documents aspect ratio. The resized document would not be distorted if  both image have the same aspect ratio.

JJMack
rikinp27770370
Participating Frequently
March 27, 2019

Hello JJMack,

Thanks for your reply.

But If i will use this Java Script then it's compulsory to install Photoshop in my PC. Am i Right?

I want to resize images without installing Photoshop So is there any SDK in Native java , any Photoshop API or any other option using that i can resize images using Java.

Thanks,

Rikin

JJMack
Community Expert
Community Expert
March 28, 2019

SuperMerlin​ Thank you for your suggestion but We have already tried ImageMagick. 

In JPG & PNG images ImageMagick resize images properly. But If we use it for multi layer TIFF images then resized image lost it's Transparency and also lost some channels. and in some CMYK images color properties is also changed.


ImageMagick site seems toe indicate Tiff Photoshop Layer can be read or ignored.   I see nothing to indicate the  it can write Tiff files with Photoshop Layers.  Only reading support was specified.   If you want to support Photoshop data why do you not want to use Photoshop.  I would think writing Photoshop Layers into a Tiff format files would be very hard to write in using Java without some library API support.

JJMack
pixxxelschubser
Community Expert
Community Expert
March 22, 2019

For clarity: Do you really mean native Java code – and not Javascript (Adobe Extendscript) ?

Is this right?

Apart from that (if you not mean Java) you can use Photoshop scripting DOM eg.

Document.resizeCanvas (width: UnitValue , height: UnitValue , anchor: AnchorPosition )

or Action-Manager-Code (you will need ScriptListener for that).