Center image inside another

Moderator: jsachs

Post Reply
elbitjusticiero
Posts: 9
Joined: October 17th, 2023, 9:22 am

Center image inside another

Post by elbitjusticiero »

Hi all! I'm trying to build a workflow to adapt vertical images to a horizontal layout by superimposing the original image to a stretched and blurred version of itself, as you often see on YouTube and elsewhere.

The step I'm stuck at is having the images align in the Composite transformation. There is no option to auto-center that I can see. And I'd like this process to be scriptable, so manually aligning the image is not an option because different images will have different dimensions.

This is the script I generated with the steps I followed until this point:

Code: Select all

script 1.0

PWP_Version ″Picture Window Pro 8.0.393″ saved ″17-octubre-2023 10:24:40″

script_directory ″″
original_script_pathname ″E:\Sebastián\Escritorio\verticaltohorizontal.script″
associated_image_pathname ″″
associated_original_pathname ″″ -1
top_level_index 18

color_management enabled 0 on_mismatch 0 on_batch_mismatch 1 on_multiple_mismatch 1 acs_profile ″″ gray_acs_profile ″″ ar_profile ″″ gray_ar_profile ″″ wcs_profile ″″ gray_wcs_profile ″″ monitor_curves_file ″″ monitor_curves_enabled 0

image index 18 caption ″Paste″ comment ″″ saved_as_pathname ″″ saved_on_date ″″ parent -1 bypass -1 same_size 1 size_specific 0 breakpoint 0 n_inputs 0 n_masks 0 command ‴paste‴
end_image

image index 29 caption ″Resize″ comment ″″ saved_as_pathname ″″ saved_on_date ″″ parent 18 bypass 0 same_size 0 size_specific 0 breakpoint 0 n_inputs 0 n_masks 0 command ‴resize 0 pixel_w 1600 pixel_h 900 physical_w 4.98 physical_h 5.97 resolution 100 memory 0.8931 percent 100 iunits 0 wunits 0 runits 0 resample 0 set 12 method 2 sharpen -0.75 display 1 auto_preview 1‴
end_image

end 2 1 18
I thought I could use the "Size to fit" transformation to bring the original image to the same size of the boundary I need, but with a transparent background. But I don't see a way to specify a transparent background so it seems it wont' work.

Any ideas will be appreciated. Thanks in advance!
jsachs
Posts: 4219
Joined: January 22nd, 2009, 11:03 pm

Re: Center image inside another

Post by jsachs »

If the vertical images are all the same proportions, I think the Layout transformation will do this.

script 1.0

PWP_Version ″Picture Window Pro 8.0.397″ saved ″17-October-2023 10:07:10″

script_directory ″″
original_script_pathname ″D:\Temp\test.script″
associated_image_pathname ″″
associated_original_pathname ″″ -1
top_level_index 10

color_management enabled 1 on_mismatch 1 on_batch_mismatch 1 on_multiple_mismatch 1 acs_profile ″sRGB Color Space Profile.icm″ gray_acs_profile ″Gamma 2.2.icm″ ar_profile ″AdobeRGB1998.icc″ gray_ar_profile ″Gamma 2.2.icm″ wcs_profile ″AdobeRGB1998.icc″ gray_wcs_profile ″Gamma 2.2.icm″ monitor_curves_file ″″ monitor_curves_enabled 0

image index 1 caption ″Paste″ comment ″″ saved_as_pathname ″″ saved_on_date ″″ parent -1 bypass -1 same_size 1 size_specific 0 breakpoint 0 n_inputs 0 n_masks 0 command ‴paste‴
end_image

image index 9 caption ″Gaussian Blur″ comment ″″ saved_as_pathname ″″ saved_on_date ″″ parent 1 bypass 0 same_size 1 size_specific 0 breakpoint 0 n_inputs 0 n_masks 1 command ‴gaussian_blur 0 radius 20 what 0 amount 1 -1 0 1 ″Amount: ″ ″Mask″ display 1 sync_scroll 1‴
end_image

image index 10 caption ″Layout″ comment ″″ saved_as_pathname ″″ saved_on_date ″″ parent -1 bypass -1 same_size 0 size_specific 0 breakpoint 0 n_inputs 257 n_masks 256 command ‴layout 0 nx 3600 ny 2400 dpi 300 units 1 bg_color ffffff bgscale 1.4206 description ″″ snapgrid 0.25 displaygrid 1 current_tab 0 nobjects 1 curobject 0 display 1 sequence0 0 bgtype0 0 object_color0 808080 amount0 1 -1 0 1 ″Amount:″ ″Mask″ dx00 3 dy00 0 dx10 9 dy10 8 cx00 0 cy00 0 cx10 1 cy10 1 proportions0 1 orientation0 0 rotation_angle 0 text0 ″″ font_name0 ″Arial″ fontsize0 36 italic0 0 bold0 0 text_color0 0 linespacing0 1 alignment0 4 delta0 0.5 borderwidth0 0 border_color0 0‴
input base_image 10 input_number 0 index 9 caption ″Background″
input base_image 10 input_number 1 index 1 caption ″1″
end_image

end 2 1 10
Jonathan Sachs
Digital Light & Color
elbitjusticiero
Posts: 9
Joined: October 17th, 2023, 9:22 am

Re: Center image inside another

Post by elbitjusticiero »

jsachs wrote: October 17th, 2023, 10:08 am If the vertical images are all the same proportions
They aren't. But I think I managed to do it with Layout!

Thank you so much! I'll test what I have and let you know if I run into any problems.
elbitjusticiero
Posts: 9
Joined: October 17th, 2023, 9:22 am

Re: Center image inside another

Post by elbitjusticiero »

It works perfectly. I've tested it with several images and so far it's been flawless. Also, very quick when run from the command line!

This is the script I'm using to do what I want:

Code: Select all

script 1.0

PWP_Version ″Picture Window Pro 8.0.393″ saved ″17-octubre-2023 11:29:35″

script_directory ″″
original_script_pathname ″E:\Sebastián\Escritorio\verticaltohorizontal.script″
associated_image_pathname ″″
associated_original_pathname ″″ -1
top_level_index 45

color_management enabled 1 on_mismatch 1 on_batch_mismatch 1 on_multiple_mismatch 1 acs_profile ″sRGB Color Space Profile.icm″ gray_acs_profile ″Gamma 2.2.icm″ ar_profile ″AdobeRGB1998.icc″ gray_ar_profile ″Gamma 2.2.icm″ wcs_profile ″AdobeRGB1998.icc″ gray_wcs_profile ″Gamma 2.2.icm″ monitor_curves_file ″″ monitor_curves_enabled 0

image index 1 caption ″Paste″ comment ″″ saved_as_pathname ″″ saved_on_date ″″ parent -1 bypass -1 same_size 1 size_specific 0 breakpoint 0 n_inputs 0 n_masks 0 command ‴paste‴
end_image

image index 2 caption ″Size to Fit″ comment ″″ saved_as_pathname ″″ saved_on_date ″″ parent 1 bypass 0 same_size 0 size_specific 0 breakpoint 0 n_inputs 1 n_masks 0 command ‴size_to_fit 0 method 1 nx 800 ny 450 dpi 100 border_color ffffff cx0 0 cy0 0.2668 cx1 1 cy1 0.7349 display 2 auto_preview 1‴
end_image

image index 10 caption ″Gaussian Blur″ comment ″″ saved_as_pathname ″″ saved_on_date ″″ parent 2 bypass 0 same_size 1 size_specific 0 breakpoint 0 n_inputs 0 n_masks 1 command ‴gaussian_blur 0 radius 22 what 0 amount 1 -1 0 1 ″Amount: ″ ″Mask″ display 2 sync_scroll 1‴
end_image

image index 18 caption ″Paste″ comment ″″ saved_as_pathname ″″ saved_on_date ″″ parent -1 bypass -1 same_size 1 size_specific 0 breakpoint 0 n_inputs 0 n_masks 0 command ‴paste‴
end_image

image index 44 caption ″Resize″ comment ″″ saved_as_pathname ″″ saved_on_date ″″ parent 18 bypass 0 same_size 0 size_specific 0 breakpoint 0 n_inputs 0 n_masks 0 command ‴resize 0 pixel_w 498 pixel_h 450 physical_w 4.98 physical_h 5.97 resolution 100 memory 0.8931 percent 100 iunits 0 wunits 0 runits 0 resample 0 set 1 method 2 sharpen -0.75 display 1 auto_preview 1‴
end_image

image index 45 caption ″Layout″ comment ″″ saved_as_pathname ″″ saved_on_date ″″ parent -1 bypass -1 same_size 0 size_specific 0 breakpoint 0 n_inputs 257 n_masks 256 command ‴layout 0 nx 800 ny 450 dpi 300 units 0 bg_color ffffff bgscale 1 description ″″ snapgrid 0.25 displaygrid 1 current_tab 0 nobjects 1 curobject 0 display 1 sequence0 0 bgtype0 0 object_color0 808080 amount0 1 -1 0 1 ″Amount:″ ″Mask″ dx00 0 dy00 0 dx10 2.6667 dy10 1.5 cx00 0 cy00 0 cx10 1 cy10 1 proportions0 1 orientation0 0 rotation_angle 0 text0 ″″ font_name0 ″Arial″ fontsize0 36 italic0 0 bold0 0 text_color0 0 linespacing0 1 alignment0 4 delta0 0.5 borderwidth0 0 border_color0 0‴
  input base_image 45 input_number 0 index 10 caption ″Background″
  input base_image 45 input_number 1 index 44 caption ″1″
end_image

end 4 1 18 41 45
Post Reply