Jpeg Vs.Png

Derm wrote on 11/1/2009, 5:43 AM
Hi,
I have a problematic project that uses hundreds of jpegs. I know now from help in this forum that my jpegs are unnecessarily large. I have the option of easily resizing all of them in Photoshop or converting them to png.
From reading the forum, png seems to be a friendlier format for Vegas. However if I convert to png they will not automatically open in the project as they will be a different file extension. Manually replacing them is not practicle. Is there a way to get Vegas to auto load the png files where there was once jpegs? Is it worth doing? I am on 9c.
Thanks
Derm

Comments

rs170a wrote on 11/1/2009, 6:28 AM
Is there a way to get Vegas to auto load the png files where there was once jpegs?

I hope to be proven wrong but there's no way that I'm aware of :-(

I have the option of easily resizing all of them in Photoshop

Since you don't want to manually replace them, that's your only option.
Use Photoshop to do a batch resize to a new folder in your project master folder, making sue to keep the original names.
Move the original images into a new folder in your project master folder.
Start up Vegas and, when it says it can't find the original images, point it to the new folder.
Once it finds the first one, it should say something along the lines of "also found image2.jpg. Do you want me to use it?"
Click "yes to all" and it should load all of the resized images.
As soon as this is done, save the project as a new version and resume editing.

Mike
Coursedesign wrote on 11/1/2009, 7:16 AM
This is where I wish Vegas had XML support.

With that, this would have been a simple "*.jpg" to "*.png" text search-and-replace in the project file (after doing the batch conversion of the images).
Laurence wrote on 11/1/2009, 9:09 AM
You could try saving to an EDL, then converting all the instances of .jpg to .png.
xberk wrote on 11/1/2009, 9:24 AM
If it comes down to manually replacing them, you can add them as "takes" one by one and thereby preserving all the properties of the original jpegs like length, pan/crop etc.

Paul B .. PCI Express Video Card: EVGA VCX 10G-P5-3885-KL GeForce RTX 3080 XC3 ULTRA ,,  Intel Core i9-11900K Desktop Processor ,,  MSI Z590-A PRO Desktop Motherboard LGA-1200 ,, 64GB (2X32GB) XPG GAMMIX D45 DDR4 3200MHz 288-Pin SDRAM PC4-25600 Memory .. Seasonic Power Supply SSR-1000FX Focus Plus 1000W ,, Arctic Liquid Freezer II – 360MM .. Fractal Design case ,, Samsung Solid State Drive MZ-V8P1T0B/AM 980 PRO 1TB PCI Express 4 NVMe M.2 ,, Wundiws 10 .. Vegas Pro 19 Edit

A. Grandt wrote on 11/1/2009, 9:35 AM
I just made this script, to see if I could, it is the first Vegas script I've ever made.

Jpg2Png.js

/*
* Convert all jpg's to png
*/

import System;
import System.IO;
import System.Windows.Forms;
import Sony.Vegas;

var outlist = "JPG Images: ";

// enumerate the files in the Media Pool
var mediaEnum = new Enumerator(Vegas.Project.MediaPool);

while (!mediaEnum.atEnd()) {
var media = mediaEnum.item();

if (media.FilePath.match(/jpg$/i)) {
var newpath = media.FilePath.substring(0, media.FilePath.length - 3) + "png";

if (File.Exists(newpath)) {
outlist += "\n" + media.FilePath + " -> " + newpath;
media.ReplaceWith(new Media(newpath));
}
}
mediaEnum.moveNext();
}

MessageBox.Show(outlist);


Save it to a .js file in the Vegas scripts directory and run it from Vegas.

Edit: The above code start at the /*, ignore the "Code Block:" text.
MPM wrote on 11/1/2009, 10:15 AM
Probably Really Stupid question -- please forgive...

Since Vegas/DVDA are so good at opening files after renaming the extensions, what would happen if you re-named the png conversions back tp jpg? If it worked there's tons of utilities to rename a whole folder full of them.
A. Grandt wrote on 11/1/2009, 10:23 AM
You probably could just rename the png's to .jpg, but I would not recommend it, we do ourselves often use these extensions to identify the nature of the media.
rs170a wrote on 11/1/2009, 11:13 AM
A. Grandt, when I run your script, I get the following message:

C:\Program Files\Sony\Vegas Pro 9.0\Script Menu\Jpg2Png.js(1) : Syntax error. Write 'var identifier : Type' rather than 'Type identifier' to declare a typed variable
C:\Program Files\Sony\Vegas Pro 9.0\Script Menu\Jpg2Png.js(1) : Variable 'Code' has not been declared

Maybe it's because I'm not certain what to do.
I loaded a project that had 116 JPGs in it.
I also loaded all PNGs that I batch converted from these JPGs into the Project Media.
What next?

Mike
jetdv wrote on 11/1/2009, 12:15 PM
You don't include "code block". The first line is /**
A. Grandt wrote on 11/1/2009, 12:42 PM
jetdv is right, you have to remove the first line "Code block:"

The script looks for the .png in the same directory as the .jpg are in, and adds the .png to the Project Media as a result of the media.ReplaceWith command.
rs170a wrote on 11/1/2009, 4:14 PM
You don't include "code block". The first line is /**

Doh!!
A. Grandt, thank you VERY much.
This script is going to come in very handy as I use this feature a lot.
BTW, congratulations on your first script as, IMO, it's a winner :-)

Mike
A. Grandt wrote on 11/1/2009, 4:56 PM
Thanks :)

if you have 100+ instances that need to be replaced, you mihgt want to remove the last line, the one with "MessageBox.Show(outlist);"

That is the one that makes the pop-up message with which images were replaced. I can do a slight update with a replacemnet count instead if you like.

I forgot to mention that the script only replaces the .jpg if the corrosponding .png exists.
rs170a wrote on 11/1/2009, 7:13 PM
if you have 100+ instances that need to be replaced...

I did, saw the message and closed it out with no problems.
Nice to know that there's a fix for that so thanks again.

I forgot to mention that the script only replaces the .jpg if the corrosponding .png exists.

That's why I use IrfanView as I can tell it to change formats only and it's very quick.

Mike
A. Grandt wrote on 11/1/2009, 7:46 PM

/*
* Convert all jpg's to png
*/

import System;
import System.IO;
import System.Windows.Forms;
import Sony.Vegas;

var count = 0;

// enumerate the files in the Media Pool
var mediaEnum = new Enumerator(Vegas.Project.MediaPool);

while (!mediaEnum.atEnd()) {
var media = mediaEnum.item();

if (media.FilePath.match(/jpg$/i)) {
var newpath = media.FilePath.substring(0, media.FilePath.length - 3) + "png";

if (File.Exists(newpath)) {
media.ReplaceWith(new Media(newpath));
count++;
}
}
mediaEnum.moveNext();
}

MessageBox.Show("JPG images replaced: " + count);


Same as the previous script, but without the lengthy dialog, this one just tells you how many have been changed. Again, if you don't want any such feedback, you can just remove the last line, and the "var count = 0;" and "count++;" lines as well.