Skip to main content
Participating Frequently
January 6, 2021
Question

Batch Resizing Images

  • January 6, 2021
  • 3 replies
  • 1430 views

Hey,

 

I have been batch resizing a lot of images to 1000 x 1000 pixels recently for clients websites and I have setup a task that runs through actions I have created, these are:

 

  1. Trim

  2. Resize image to 900 x 900px

  3. Resize canvas to 1000 x 1000px

  4. Save for web

 

This works fine for most images however, some images have hidden artifacts on them which causes the trim to not go right to the edges of the image which means the resized image is a lot smaller than it should be, does anyone know if there is a way or removing these artifacts (which can be in different places on different image) without having to do them manually?

 

Here is an example of one of the images, you can see on the right the image looks like it is just a pure which background, but if I add a levels adjustment with the black arrow all the way to the right you will be able to see the artifacts.

 

Thanks

This topic has been closed for replies.

3 replies

JJMack
Community Expert
Community Expert
January 6, 2021

Looking at you steps 

  1. Trim

  2. Resize image to 900 x 900px

  3. Resize canvas to 1000 x 1000px

  4. Save for web]

 

 

I see 1. Trim without any information of the settings used in the Trim Dialog this step may or may not change the documents canvas  size.

 

2, Resize image to 900 x 900px the will make the Canvas size 900px by 900px and resample the image to that sized canvas.  It will distort any image that did not have a 1:1 Aspect ratio  This is not something you should want to do, You  should  use menu File>Automate>Fit Image... 900px x900px soe  the image will retain its aspect ratio and bot distort.  The document canvas  will be 900px px 900px or smaller where one dimension will be 900px.

 

3. Canvas Size 1000px  by 1000px will make the canvas size  1000px by 1000px adding a border around the resized image. The Added canvas will be empty if there is no background layer or the added pixels will be the background color or the color specified in the Canvas sized Dialog.

 

 

4. Save For web will save the 1000px by 1000px document into an image file type specified in the save for web dialog.  If Jpeg and the boarder added was empty save for web will fill the boarder with background colored pixels for Jpeg file format does not support transparency.  PNG does.

JJMack
matt3mAuthor
Participating Frequently
January 6, 2021

Hi JJMack,

 

I should have been more specific with my steps, I have an action that trims both options and the resize is using fit image rather than image resize, sorry that's my mistake.

 

I am saving all images as a jpeg so a transparent background wouldn't matter as it will be added automatically.

 

Thanks

 

Matt 🙂

JJMack
Community Expert
Community Expert
January 6, 2021

Why do you want 1:1 square images?   If you really do want that you should incorporate image cropping in your action so the image will not distort and you will have your 50px boarders.  Using my AspectRatioSelection plug-in script it would be easy the set the max size centered 1:1 aspect selection for your images then use an arrows  key to tweak the selection position for best composition. when you hit enter the action would make the 1:1 crop resize the image 900x900px and then add the 50px boarders.  You should use the Action with an images processor so you can specified where to saved the cropped resized images into the file type you want saved.   You could turn off the interactive transform selection step if a centered 1:1 crop will do. The action would batch and no intervension woul be done for positioning the crop 

JJMack
Bojan Živković11378569
Community Expert
Community Expert
January 6, 2021

Can you find some pattern like all images can be cropped using selection 2000x2000 pixels from center to remove artifacts and unwanted areas. Later downsample to 900x900 and add extra canvas. If old images which you are processing share same dimensions then chances are you can find some pattern which will work without brainstorming too much what can give results but also may fail. I am always trying to think simple and try to find simple solution before adding complexity.

matt3mAuthor
Participating Frequently
January 6, 2021

I've been resizing different images so one was for a bed company, another for a sweet shop so the images have all been different so would need it to be suitable for all images rather than just a set of one as I will be using it in the future as well 🙂

Stephen Marsh
Community Expert
Community Expert
January 6, 2021

Perhaps start with Select > Select Subject, then Image > Crop. Then add in the trim command using upper left pixel. Then a second trim using lower right pixel (or use a single trim based on transparency if there isn't a background).

matt3mAuthor
Participating Frequently
January 6, 2021

Thanks for the suggestion, I just tested it on a few images and whilst it worked with two images that are more simple one of the more complex one the select subject didn't do a great job and ended up cropping the top of the image off.

 

I posted the same question on Reddit and someone suggested using a script but I'm not familiar with Javascript.

Stephen Marsh
Community Expert
Community Expert
January 6, 2021

A script may or may not be needed. It is easy to say "use a script" - but what will the script do that you otherwise can't do in this case?

 

If every image is on a white background, another option would be to load a selection based on the image pixel content, the trick being to remove the "invisible" artifacts.