From: Marok on
Hello!
I'm using Paint Shop Pro 8.01 (US).

In a specified folder, I need to convert all JPGs into PNGs.

I tried with this script:

def Do(Environment):
# FileSaveAs
App.Do( Environment, 'FileSaveAs', {
'Encoding': {
'PNG': {
'Interlaced': App.Constants.Boolean.false,
'OptimizedPalette': App.Constants.Boolean.true
}
},
'FileFormat': App.Constants.FileFormat.PNG,
'FormatDesc': u'Portable Network Graphics',
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.AllAlways
},
'DefaultProperties': []
})

It works for a single image, but, if it's run as a batch process, it gives me this error:

App.Do( Environment, 'FileSaveAs', {
RuntimeError: The file name specified is invalid.

How can I tell PSP to keep the original file name just changing the extension into ".png"?

Thanks!

MaRoK
From: Fred Hiltz on
David Gilbert wrote:
> On Sat, 10 Feb 2007 14:29:22 +0100, Marok
> <alex.marok(a)gmail.com>
> wrote:
>> ..............................................
>> How can I tell PSP to keep the original file name just
>> changing the extension into ".png"?
>
> Why use a script: just use the Batch Process >Save Mode-New
> Type (png). This will save with original file name.

Unfortunately, the PSP 8 Batch does not offer the option of 24-bit
color with PNG files directly (an oversight that neither Jasc nor
Corel has corrected). Marok will need to specify it in a script.

Marok, the script you showed invokes the paletted version of PNG. I
doubt that is what you want for JPG files, as they are probably
photos. To invoke the 24-bit full-color version, open a file and
record a script while you use the PNG Optimizer to save it that way.

The PSP 8.10 BP runs such a script without error here. Have you
named it correctly in the Script section of the Batch Process
dialog? Have you selected Save Mode = Obey Script?

If it still fails, try updating PSP to the latest version, 8.10.
--
Fred Hiltz, fhiltz at yahoo dot com

From: willy on
I think something like this will work in v8
from JascApp import *
import os.path

def ScriptProperties():
return {
'Author': u'',
'Copyright': u'',
'Description': u'',
'Host': u'Paint Shop Pro',
'Host Version': u''
}

def Do(Environment):

False = App.Constants.Boolean.false
True = App.Constants.Boolean.true

ImageInfo = App.Do( Environment, 'ReturnImageInfo' )

FileName, file_type = os.path.splitext( ImageInfo['FileName'] ) #
splits out file type.

# PNG Optimizer
App.Do( Environment, 'PNGOptimizer', {
'TypeOfTransparency':
App.Constants.TransparencyType.NoTransparency,
'Tolerance': 1,
'BoostAmount': 1,
'IncludeWindowsColors': False,
'TypeOfImage': App.Constants.ImageType.TrueColor,
'DitherPercent': 0,
'PaletteType':
App.Constants.ColorSelection.OptimizedOctreePalette,
'FileSubFormat': App.Constants.SubFormat.NonInterlaced,
'BoostSelectedColors': False,
'TransparentArea': App.Constants.Transparency.None,
'FileName': FileName+'.png',
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
}
})

Batch process use the script save option in batch process. Silent checked.


"Marok" <alex.marok(a)gmail.com> wrote in message
news:45cdc8aa$0$25470$4fafbaef(a)reader3.news.tin.it...
> Hello!
> I'm using Paint Shop Pro 8.01 (US).
>
> In a specified folder, I need to convert all JPGs into PNGs.
>
> I tried with this script:
>
> def Do(Environment):
> # FileSaveAs
> App.Do( Environment, 'FileSaveAs', {
> 'Encoding': {
> 'PNG': {
> 'Interlaced': App.Constants.Boolean.false,
> 'OptimizedPalette': App.Constants.Boolean.true
> }
> },
> 'FileFormat': App.Constants.FileFormat.PNG,
> 'FormatDesc': u'Portable Network Graphics',
> 'GeneralSettings': {
> 'ExecutionMode': App.Constants.ExecutionMode.Default,
> 'AutoActionMode': App.Constants.AutoActionMode.AllAlways
> },
> 'DefaultProperties': []
> })
>
> It works for a single image, but, if it's run as a batch process, it gives
> me this error:
>
> App.Do( Environment, 'FileSaveAs', {
> RuntimeError: The file name specified is invalid.
>
> How can I tell PSP to keep the original file name just changing the
> extension into ".png"?
>
> Thanks!
>
> MaRoK


From: Fred Hiltz on
David Gilbert wrote:
> On Sat, 10 Feb 2007 16:18:22 GMT, "Fred Hiltz" <not(a)home.ca>
> wrote:
>
>> Unfortunately, the PSP 8 Batch does not offer the option of
>> 24-bit color with PNG files directly (an oversight that
>> neither Jasc nor Corel has corrected). Marok will need to
>> specify it in a script.
>
> Fred,
> I know it doesn't offer the option on the tab but I've just
> tried saving 8bit/ch jpgs to png using the batch process and
> they end up still as 8bit/ch and the no. of colours is the
> same after processing (this is using 9 & X).

Hi David. I just tried it in 8.10 and it writes 8 bit/ch there, too,
just as you say. Silly me, believing the settings in the options
dialog! Thanks for pointing this out. It will come in handy again,
no doubt.
--
Fred Hiltz, fhiltz at yahoo dot com

From: JoeB on
"willy" <willy(a)hotmail.com> wrote in
news:QLydna3cqNFBhFPYnZ2dnUVZ_rSjnZ2d(a)adelphia.com:

> I think something like this will work in v8
> from JascApp import *
> import os.path
>
> def ScriptProperties():
> return {
> 'Author': u'',
> 'Copyright': u'',
> 'Description': u'',
> 'Host': u'Paint Shop Pro',
> 'Host Version': u''
> }
>
> def Do(Environment):
>
> False = App.Constants.Boolean.false
> True = App.Constants.Boolean.true
>
> ImageInfo = App.Do( Environment, 'ReturnImageInfo' )
>
> FileName, file_type = os.path.splitext( ImageInfo['FileName'] )
> #
> splits out file type.
>
> # PNG Optimizer
> App.Do( Environment, 'PNGOptimizer', {
> 'TypeOfTransparency':
> App.Constants.TransparencyType.NoTransparency,
> 'Tolerance': 1,
> 'BoostAmount': 1,
> 'IncludeWindowsColors': False,
> 'TypeOfImage': App.Constants.ImageType.TrueColor,
> 'DitherPercent': 0,
> 'PaletteType':
> App.Constants.ColorSelection.OptimizedOctreePalette,
> 'FileSubFormat': App.Constants.SubFormat.NonInterlaced,
> 'BoostSelectedColors': False,
> 'TransparentArea': App.Constants.Transparency.None,
> 'FileName': FileName+'.png',
> 'GeneralSettings': {
> 'ExecutionMode':
App.Constants.ExecutionMode.Default,
> 'AutoActionMode':
App.Constants.AutoActionMode.Match,
> }
> })
>
> Batch process use the script save option in batch process. Silent
> checked.
>

I tested it in v.8.01 and it works fine, Willy.

Regards,

JoeB