Transparent PNG using batch and script

Moderator: Kathy_9

Post Reply
User avatar
Tony Lenton
Posts: 32
Joined: Wed Jan 18, 2006 8:28 am
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Intel DH55TC
processor: Intel Core i5 3.20 GHz
ram: 12GB
Video Card: GeForce GTX 1060
sound_card: On board Realtek High Def Audio
Hard_Drive_Capacity: 4500 GB
Monitor/Display Make & Model: Lenovo S27i
Corel programs: PSP X6 PSP2020
Location: Frenaros, Cyprus

Transparent PNG using batch and script

Post by Tony Lenton »

I'm in the process of creating an mpg of a load of photos and movies taken on my camera. I want to have a small transparent border around the slides so they fit in the "safe area" of the TV and I can show a moving image behind the slides (especially the portrait ones).

I know that I can resize the photos and then resize the canvas to give me my border and I can then do "Save As" PNG to get the border transparent.

I have a few hundred photos so what I want to know is, is it possible to utilise PSPs built in "Batch Process" on the files and make use of the "Use Script" option.

I have recorded a script which does all the resizing and saving but when I look at the script it has the name of the file hard coded in it.

What I want to do is use the "Batch Process" to select all the files, run the script on them and then save them into a different folder (something I've done many time for other projects just not with the transparent bit). Does anyone know if this is possible in this case?

Thanks
LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8-2023
Location: USA

Re: Transparent PNG using batch and script

Post by LeviFiction »

Don't save inside the script.

Yes, it is possible to make the script smart enough. But, it's best to use what's already at your disposal to save time.

Batch Processing has all of the save functionality you need built in. Do all the processing with a script, but once the script is finished running let the Batch Process command do the saving.

So, re-record the script, but don't save the image. Or edit the current script and remove the saving portion.

Then inside Batch Process, under Save Mode select "New Type" this is create a copy of the file and let you choose the file type.

Select PNG from the Save Options.

Choose the folder

And if you wanted a special sequenced name you can do so with the "New File Name" section. Click the Modify button and add any fields you want to the new name. For example I used Custom Text and Sequence. So I got a set of images with names like "MPG_01" and "MPG_02" etc.

That will do everything you want. I just tested it and the PNGs maintained their transparency.
https://levifiction.wordpress.com/
BrianCee
Posts: 5487
Joined: Sat Jan 21, 2012 1:04 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
ram: 8GB
Hard_Drive_Capacity: 4TB
Monitor/Display Make & Model: HP
Corel programs: VS X4,X5,X6,X7,X8, X9, X10, 2018 , 2019
Location: London England UK

Re: Transparent PNG using batch and script

Post by BrianCee »

I do not use PSP so can't help with your script but I do wonder what you are going to use to make your slide show - if you were going to use Corel VideoStudio for instance which I am familiar with there is no need for any transparentcy in the images to do what you want
User avatar
Tony Lenton
Posts: 32
Joined: Wed Jan 18, 2006 8:28 am
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Intel DH55TC
processor: Intel Core i5 3.20 GHz
ram: 12GB
Video Card: GeForce GTX 1060
sound_card: On board Realtek High Def Audio
Hard_Drive_Capacity: 4500 GB
Monitor/Display Make & Model: Lenovo S27i
Corel programs: PSP X6 PSP2020
Location: Frenaros, Cyprus

Re: Transparent PNG using batch and script

Post by Tony Lenton »

Hi Levi

Thanks, this is what I thought but apparently this only works if the PNG was ORIGINALLY saved using the "Options>Run Optimiser buttons and Transparency tab" when saving it. Unfortunatelly if you click on the Options button in Batch mode the "Run Optimiser" option is missing and the PNG previously saved without transparency is resaved in the same way.

Brian, I'm using Sony Movie Studio and if I just load the photos straight in there is no problem with transparency. The problem comes about because I want to avoid having any of my photos cut off by the so called "Safe Area" that most video editors allow for TV overscanning. This is normally up to 10% for titles and 20% for the video and hence expanding the canvas to surround the photos so they fit inside this area.

Oh well, I'll just have to fill the extended canvas with a background and not have a moving one.

I'm currently using X6 but I re-installed PSPX to check this out and unfortunatelly it works exactly the same.

Thanks
LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8-2023
Location: USA

Re: Transparent PNG using batch and script

Post by LeviFiction »

You don't have to save the original PNG that way.

In fact you don't have to start with a PNG at all. When I did my test I did it on JPGs, converted them to PNGs, and the transparency remained.

I also just ran the test on a PNG image that I saved using the Optimizer with transparency turned off. And when I ran the batch process it maintained the transparency.

So, my first guess would be it's your script.

Something to keep in mind, Canvas Size, when run on a background layer which does not support transparency, will always use a solid color to fill in the new canvas areas. If, however, Canvas Size is run on a regular raster layer, it'll leave the new canvas area transparent.

If your original PNG does not have any transparent areas PSP will import it as a background layer, not as a raster layer. As such the result of using Canvas Size on the layer is it will be filled with the current background color. To fix this, re-record your script. The first action should be "Promote Background Layer" this will make sure that the layer is always converted to a raster first.

Then use Canvas Size command. And save the script. The batch process should now create layers with transparency and the PNGs will maintain that transparency.

You can see a screen shot of the "Edit Script" dialog with the script that I'm using.
script.png
script.png (6.5 KiB) Viewed 6213 times
And if you would like, I even recorded a video demonstrating how I setup my test to show it in action to see if that helps. I honestly think it's just that one thing, making sure the layer is a full raster layer and not a background layer.
https://levifiction.wordpress.com/
BrianCee
Posts: 5487
Joined: Sat Jan 21, 2012 1:04 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
ram: 8GB
Hard_Drive_Capacity: 4TB
Monitor/Display Make & Model: HP
Corel programs: VS X4,X5,X6,X7,X8, X9, X10, 2018 , 2019
Location: London England UK

Re: Transparent PNG using batch and script

Post by BrianCee »

I am surprised you cannot do it in Sony Movie Studio - my screenshot below shows VideoStudio displaying two portrait images within the TV safe area over a video background. No transparency any where Image two is selected in order to display the safe area border
click the image to enlarge it
click the image to enlarge it
User avatar
Tony Lenton
Posts: 32
Joined: Wed Jan 18, 2006 8:28 am
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Intel DH55TC
processor: Intel Core i5 3.20 GHz
ram: 12GB
Video Card: GeForce GTX 1060
sound_card: On board Realtek High Def Audio
Hard_Drive_Capacity: 4500 GB
Monitor/Display Make & Model: Lenovo S27i
Corel programs: PSP X6 PSP2020
Location: Frenaros, Cyprus

Re: Transparent PNG using batch and script

Post by Tony Lenton »

Hi

Thanks chaps, now sorted.

Levi, this is just what I wanted and yes it was the layer step that I hadn't done. (Strangely enough I was laying in bed last thinking "I wonder if the problem is something to do with layers").

Brian, I've had a play with Movie studio and it is possible to achieve the effect but it means either "pan and zooming" each photo to size them inside the guides or otherwise making a track size adjustment which unfortunately affects everything on the track including any video on it. Actually while writing this I've realised that I could place all the still photos on one track and size it, and place my videos on a second track without sizing it. My moving background would then go on a third track.

Once again, thanks to both of you.
Post Reply