Script - Open Animated WebP

Moderator: Kathy_9

Post Reply
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

Script - Open Animated WebP

Post by LeviFiction »

Script Name: SplitImage
Download Link: https://drive.google.com/file/d/1YLeTvr ... sp=sharing
Compatability: X6 - 2018 (, 2018)
Requirements: Place in Scripts-Trusted Folder
Description:

So, the WebP format supports Animated Frames. However, PSP does not support loading these kinds of images.

This script makes use of some command line tools provided by Google to convert the frames of an animated webP image into individual PNG images and then load each frame as a layer onto an existing image.

Installation Instructions:
1) First you need to download the libwebp library of programs - https://developers.google.com/speed/webp/download
2) Unzip the folder somewhere you will remember
3) Make note of the path to the bin folder inside the libwebp folder e.g. c:\\libwebp\\bin\\
4) Install Script into the Scripts-Trusted folder of your installation
5) Open the script in a text editor like Notepad or Notepad++. Look for the line that says

Code: Select all

################################################################
# Set Directory of libwebp tools
################################################################
wd = "C:\\Users\\<YourUsername>\\<Folder>\\libwebp\\bin\\"

Updated the directory of the wd variable to point to the folder location.
6) Run the script

I usually include a video to go with this for more visual learners. But I'm exhausted and my mobile hotspot is running out of data. So maybe later.
https://levifiction.wordpress.com/
migf1
Posts: 510
Joined: Fri Apr 03, 2020 3:09 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit

Re: Script - Open Animated WebP

Post by migf1 »

Thank you Levi!

However, I'm getting an error. The script does create the frames as dump_XXX.png files, but it saves them in the libwepb folder, while it tries to open them from the path of the original image.

In other words, I saved a test webp animation on my Desktop, tried the script and is giving me this error: http://prntscr.com/sdo917 (the dump files are not on my desktop, they are in the libwebp folder).

PS. Btw, how about saving them in %temp% instead? It is Windows standard temporary folder. Also, I don't know if python gives you a way to know if the script completed successfully or no (like the 0 exit code in C programs), or if it has error/exception catch mechanisms (like the try-block in C++) but if it does, maybe it's a good idea to delete the dump files if the script fails? Actually that's the main reason I'm suggesting saving the dump files to %temp%. Most, if not all, disk cleanup programs clean that folder.
Good Unofficial PaintShop Pro Tutorials: Creation CasselMake Shop ProHEC Image EditingLeviFiction PSP Basics
(plus my own Gimp & Stuff)
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: Script - Open Animated WebP

Post by LeviFiction »

Well, the original thought was if it did fail people could still manually drag the files into PSP. In fact the only reason my script is so long and complicated is because I also plan on creating a simple animated webp exporter and this script gives each frame a long name with all relevant parameters taken from the file directly. Otherwise this would be way easier.

As for the error you received that's because I keep forgetting to push my changes to GitHub. :p I had fixed this on my work computer but forgot to push it to the server so when I downloaded it at home I didn't notice. My bad. Anyway, it's fixed now.
https://levifiction.wordpress.com/
migf1
Posts: 510
Joined: Fri Apr 03, 2020 3:09 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit

Re: Script - Open Animated WebP

Post by migf1 »

Thank you very much Levi!

It works like a charm, I just tested it. Except 1 thing (lol)... it overrides the New Document settings to: 400x400, 300 pixels/inch, black solid background. Anyway to fix that? Maybe reading these settings before changing them, and put them back before exiting the script?
Good Unofficial PaintShop Pro Tutorials: Creation CasselMake Shop ProHEC Image EditingLeviFiction PSP Basics
(plus my own Gimp & Stuff)
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: Script - Open Animated WebP

Post by LeviFiction »

Most calls to commands will change their "last used" settings just as if you had manually entered those settings yourself. It's technically possible to read "last used" settings by using CommandInfo with the Last Used parameter, but it don't always return all of the information. I've never tried it on the New Document command so it might. But, even if I could grab the last used data I'd have to make the command create a new image using those old settings and then close it to reset the settings. I've just gotten used to this quirk of PSP's.
https://levifiction.wordpress.com/
migf1
Posts: 510
Joined: Fri Apr 03, 2020 3:09 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit

Re: Script - Open Animated WebP

Post by migf1 »

Ah, I see. No worries, no big deal. Thanks again for the script. I hope the guy who asked for it in the other thread finds this thread too.
Good Unofficial PaintShop Pro Tutorials: Creation CasselMake Shop ProHEC Image EditingLeviFiction PSP Basics
(plus my own Gimp & Stuff)
migf1
Posts: 510
Joined: Fri Apr 03, 2020 3:09 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit

Re: Script - Open Animated WebP

Post by migf1 »

Levi, I just thought of this. Why are you creating a new document? I mean, can't the main document be the first dump png image (and maybe promote the background layer)? If it can, it could spare the need of creating a new document, right?
Good Unofficial PaintShop Pro Tutorials: Creation CasselMake Shop ProHEC Image EditingLeviFiction PSP Basics
(plus my own Gimp & Stuff)
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: Script - Open Animated WebP

Post by LeviFiction »

I do that because it's part of the animated WebP format. It has a background color and initial canvas size. After each loop, and depending on the blend or disposal modes, is used to overwrite the areas. Frames are also not guaranteed to be the same size as the canvas. They can be smaller and simply positioned on the canvas.

When I finally figure out how to make the UI for exporting to an animated WebP I will also use the background layer to define the background settings.

At least that's the plan.

While I could import only the first frame first then determine if I need the canvas to be at a different size, I will still be changing the "Last Used" values of some commands to make it happen. Ultimately it's easier to just make a new image.
https://levifiction.wordpress.com/
migf1
Posts: 510
Joined: Fri Apr 03, 2020 3:09 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit

Re: Script - Open Animated WebP

Post by migf1 »

Ah, I see!

PS. The exporter sounds like a cool idea!
Good Unofficial PaintShop Pro Tutorials: Creation CasselMake Shop ProHEC Image EditingLeviFiction PSP Basics
(plus my own Gimp & Stuff)
Post Reply