How to save/export layers and pages as PNG given certain situations...

Here everybody can post his problems with PhotoLine
cadudesun
Mitglied
Beiträge: 19
Registriert: Di 14 Dez 2021 15:36

How to save/export layers and pages as PNG given certain situations...

Beitrag von cadudesun »

Hi. I'm trialing Photoline (v. 23.01).
So far, enjoying its usability and impressive functionality!
I'd appreciate your help to deal with saving/exporting layers and pages as PNG given the following situations:

a) Save current layer as PNG (including layer styles)
From a raster layer (with shadow and outline outside styles applied), I performed the menu command "Layer > Management > Save Layer".
The raster image was saved, but ignoring the layer styles.
I recorded my screen with my tests: https://tinyurl.com/y5laulob
How to save current layer as PNG also retaining the layer styles?

b) Save/Export multiple selected layers as a single PNG
I selected two layers, then performed "Save Layer". Each layer was saved independently, generating two files. This was not what I wanted.
Then, having the selected layers, I performed "Group marked layers".
From the newly grouped layer I ran "Save Layer" command, both layers were saved into as a single PNG. This is the output I was looking for.
My screen-recording: https://tinyurl.com/y3tmtsya
Aiming to save multiple selected layers as a single PNG, is the group creation really necessary?
Is the "Save Layer" from "group creation" the procedure most efficient for the job, or would there be alternative ones?

c) Save/Export each document page as PNGs (batch operation)
By manually navigating to each page of the document, I could save them (one by one) as PNGs through "File > Export".
My screen-recording: https://tinyurl.com/y6qfaj68
Is there a batch operation to Save/Export each document page as PNGs?

Thank you!
Cadu
Benutzeravatar
shijan
Mitglied
Beiträge: 1497
Registriert: Mo 23 Dez 2019 15:21
Wohnort: Ukraine

Re: How to save/export layers and pages as PNG given certain situations...

Beitrag von shijan »

Aiming to save multiple selected layers as a single PNG, is the group creation really necessary?
Is the "Save Layer" from "group creation" the procedure most efficient for the job, or would there be alternative ones?
It look logical to me as is. Just add Layer(s) to group to export with applied Styles or as thee of flatten multiple layers. In opposite way - how it possible to export layer without styles if someone in some situation needs export like this?
c) Save/Export each document page as PNGs (batch operation)
By manually navigating to each page of the document, I could save them (one by one) as PNGs through "File > Export".
My screen-recording: https://tinyurl.com/y6qfaj68
Is there a batch operation to Save/Export each document page as PNGs?
There is "Layout -> Page -> Save Pages" command. Select "From" and "To" and Check "Single Page" there.
You can also reach same command from the icon in the corner of panel.
Bild

But it can save only to PLD, so in addition you need to use to use "File -> Functions -> Batch Convert" to convert folder to PNGs.

Guess it could be request to developers to add more export formats for Pages Export.
P.S. I also noticed few bugs there:
When i use "Layout -> Page -> Save Pages" "Single Page" - it don't generate preview for PLD. Thumbnails are just white.
Also "Single Page" text is partially cropped on macOS.
PhotoLine UI Icons Customization Project: https://www.pl32.com/forum3/viewtopic.php?f=3&t=6302
Martin Huber
Entwickler
Entwickler
Beiträge: 4159
Registriert: Di 19 Nov 2002 15:49

Re: How to save/export layers and pages as PNG given certain situations...

Beitrag von Martin Huber »

cadudesun hat geschrieben: Do 16 Dez 2021 17:19 a) Save current layer as PNG (including layer styles)
From a raster layer (with shadow and outline outside styles applied), I performed the menu command "Layer > Management > Save Layer".
The raster image was saved, but ignoring the layer styles.
Yes, layer styles outside the layer bounds are cut off. I will fix that.
cadudesun hat geschrieben: Do 16 Dez 2021 17:19 b) Save/Export multiple selected layers as a single PNG
I selected two layers, then performed "Save Layer". Each layer was saved independently, generating two files. This was not what I wanted.
Then, having the selected layers, I performed "Group marked layers".
From the newly grouped layer I ran "Save Layer" command, both layers were saved into as a single PNG. This is the output I was looking for.
a) and b) can be solved by using a small action, that groups the selected layer(s), saves the group and ungroups it again.
I have attached one that does this:
ExportLayersWithStyles.actions
If you need this often, you can assign a shortcut to it in the preferences/options at "Usage > Keyboard Layout > Actions".
cadudesun hat geschrieben: Do 16 Dez 2021 17:19 c) Save/Export each document page as PNGs (batch operation)
By manually navigating to each page of the document, I could save them (one by one) as PNGs through "File > Export".
My screen-recording: https://tinyurl.com/y6qfaj68
Is there a batch operation to Save/Export each document page as PNGs?
As shijan noted, you can save single pages only as PLD.

But the following script for Windows should accomplish this for any file format. It will ask for a filename (for example "test.png") and will then save the pages (with the names "test-1.png", "test-2.png", ...).

Code: Alles auswählen

Dim pl
Dim doc
Dim page

Set pl = CreateObject("PhotoLine.Application")
Set doc = pl.ActiveDocument

pl.ArrayStartIndex = 0
pl.Visible = True
If Not doc Is Nothing Then
	Dim exportPath
	
	exportPath = doc.SaveDialog("Export Pages")
	If Len(exportPath) > 0 Then
		Dim	extenderPosition
		' Check for filename extension
		extenderPosition = InStrRev(exportPath, ".")
		If (extenderPosition > 0) Then
			Dim	extender
			Dim	basePath
			Dim	pathIndex
			' Split export path
			extender = Right(exportPath, Len(exportPath) - extenderPosition + 1)
			basePath = Left(exportPath, extenderPosition - 1)
			pathIndex = 1
			For Each page In doc
				Dim tempDoc
				' copy the active page as image
				page.Copy
				' create a temporary document
				Set tempDoc = pl.Open("", "AddToRecentFiles", FALSE)
				If Not tempDoc Is Nothing Then
					' Create filename for the active page
					exportPath = basePath & "-" & pathIndex & extender
					' If the DocumentMode is FALSE, the document will adjust its size to the background layer
					tempDoc.DocumentMode = FALSE
					' Paste the previously copied page to the temporary document
					tempDoc.Paste
					tempDoc.Export exportPath 
					' 1: CODontSave
					tempDoc.Close 1
				End If
				pathIndex = pathIndex + 1
			Next
		End If
	End If
End If
Just save it for example as "Export Pages as Image.vbs" and execute it.
Alternatively you can copy it to "%appdata%\PhotoLine\Automation" (create the Automation folder if it doesn't exist yet) and restart PhotoLine. The script will be listed in the menu at "Filter > Script".
Note: The script uses the default file format settings, so adjust them if needed before executing the script.

Martin
Du hast keine ausreichende Berechtigung, um die Dateianhänge dieses Beitrags anzusehen.
Benutzeravatar
shijan
Mitglied
Beiträge: 1497
Registriert: Mo 23 Dez 2019 15:21
Wohnort: Ukraine

Re: How to save/export layers and pages as PNG given certain situations...

Beitrag von shijan »

It is interesting that Vector Layer is saved with uncropped layer style, but Raster Layer crops everything outside. So as Martin noticed, this is just a bug.
Bild
PhotoLine UI Icons Customization Project: https://www.pl32.com/forum3/viewtopic.php?f=3&t=6302
cadudesun
Mitglied
Beiträge: 19
Registriert: Di 14 Dez 2021 15:36

Re: How to save/export layers and pages as PNG given certain situations...

Beitrag von cadudesun »

Many thanks to all of you for the replies and comprehensive directions.
It was nice to be early introduced to actions and scripts. What flexibility Photoline delivers!
shijan hat geschrieben: Do 16 Dez 2021 22:08 Guess it could be request to developers to add more export formats for Pages Export.
+1
It would be very handy.
PNG could be the first additional format implemented as "Save as type" within "Save Page(s)" dialogue :)

------------------------------
Martin Huber hat geschrieben: Fr 17 Dez 2021 12:58 a) and b) can be solved by using a small action, that groups the selected layer(s), saves the group and ungroups it again.
I have attached one that does this:
ExportLayersWithStyles.actions
It worked. Thanks for sharing the action.
May I ask you how to implement a tweak in this action, for saving the PNG output without Alpha (opaque background)?

------------------------------
Martin Huber hat geschrieben: Fr 17 Dez 2021 12:58 But the following script for Windows should accomplish this for any file format. It will ask for a filename (for example "test.png") and will then save the pages (with the names "test-1.png", "test-2.png", ...).

Code: Alles auswählen

Dim pl
Dim doc
Dim page

Set pl = CreateObject("PhotoLine.Application")
Set doc = pl.ActiveDocument

pl.ArrayStartIndex = 0
pl.Visible = True
If Not doc Is Nothing Then
	Dim exportPath
	
	exportPath = doc.SaveDialog("Export Pages")
	If Len(exportPath) > 0 Then
		Dim	extenderPosition
		' Check for filename extension
		extenderPosition = InStrRev(exportPath, ".")
		If (extenderPosition > 0) Then
			Dim	extender
			Dim	basePath
			Dim	pathIndex
			' Split export path
			extender = Right(exportPath, Len(exportPath) - extenderPosition + 1)
			basePath = Left(exportPath, extenderPosition - 1)
			pathIndex = 1
			For Each page In doc
				Dim tempDoc
				' copy the active page as image
				page.Copy
				' create a temporary document
				Set tempDoc = pl.Open("", "AddToRecentFiles", FALSE)
				If Not tempDoc Is Nothing Then
					' Create filename for the active page
					exportPath = basePath & "-" & pathIndex & extender
					' If the DocumentMode is FALSE, the document will adjust its size to the background layer
					tempDoc.DocumentMode = FALSE
					' Paste the previously copied page to the temporary document
					tempDoc.Paste
					tempDoc.Export exportPath 
					' 1: CODontSave
					tempDoc.Close 1
				End If
				pathIndex = pathIndex + 1
			Next
		End If
	End If
End If
Just save it for example as "Export Pages as Image.vbs" and execute it.
Alternatively you can copy it to "%appdata%\PhotoLine\Automation" (create the Automation folder if it doesn't exist yet) and restart PhotoLine. The script will be listed in the menu at "Filter > Script".
Note: The script uses the default file format settings, so adjust them if needed before executing the script.
Thanks for sharing the script.
Although I followed your instructions and ran the script both as .vbs and directly within Photoline, always an error is popping up:
Photoline_SUP_Script Error.png
I'm running the portable version (Photoline not installed in Win11).
Could it be triggering the error? In that case, could you please share a script compatible with Photoline portable?
Du hast keine ausreichende Berechtigung, um die Dateianhänge dieses Beitrags anzusehen.
Benutzeravatar
Gerhard Huber
Entwickler
Entwickler
Beiträge: 4143
Registriert: Mo 18 Nov 2002 15:30
Wohnort: Bad Gögging

Re: How to save/export layers and pages as PNG given certain situations...

Beitrag von Gerhard Huber »

cadudesun hat geschrieben: Sa 18 Dez 2021 01:08 I'm running the portable version (Photoline not installed in Win11).
Could it be triggering the error? In that case, could you please share a script compatible with Photoline portable?
If you don't install PhotoLine, you can't use Scripting.
Martin Huber
Entwickler
Entwickler
Beiträge: 4159
Registriert: Di 19 Nov 2002 15:49

Re: How to save/export layers and pages as PNG given certain situations...

Beitrag von Martin Huber »

You can register PhotoLine for scripting from command line with

Code: Alles auswählen

PhotoLine.exe /RegisterPerUser
Martin
cadudesun
Mitglied
Beiträge: 19
Registriert: Di 14 Dez 2021 15:36

Re: How to save/export layers and pages as PNG given certain situations...

Beitrag von cadudesun »

Martin Huber hat geschrieben: Sa 18 Dez 2021 11:19 You can register PhotoLine for scripting from command line with

Code: Alles auswählen

PhotoLine.exe /RegisterPerUser
Martin
Thank you! It worked.
Just documenting further how to register Photoline portable for scripting:
The syntax above needs to be performed from command line (cmd) set within the portable directory of Photoline.

--------------------------------------------------

Regarding:
Martin Huber hat geschrieben: Fr 17 Dez 2021 12:58 a) and b) can be solved by using a small action, that groups the selected layer(s), saves the group and ungroups it again.
I have attached one that does this:
ExportLayersWithStyles.actions
Could you please inform whether it's possible to tweak this action, for saving the PNG output without Alpha (opaque background)?
I'd like to use two versions of the action: as it is, for exporting with transparency; and the new one for exporting with background color.
Martin Huber
Entwickler
Entwickler
Beiträge: 4159
Registriert: Di 19 Nov 2002 15:49

Re: How to save/export layers and pages as PNG given certain situations...

Beitrag von Martin Huber »

cadudesun hat geschrieben: So 19 Dez 2021 14:23
Martin Huber hat geschrieben: Fr 17 Dez 2021 12:58 a) and b) can be solved by using a small action, that groups the selected layer(s), saves the group and ungroups it again.
I have attached one that does this:
ExportLayersWithStyles.actions
Could you please inform whether it's possible to tweak this action, for saving the PNG output without Alpha (opaque background)?
You should be able to edit the options of an action step by double-clicking it. Sadly, that doesn't work with a "Save Layer(s)" action step. I will fix that.

If you record the "Save Layer(s)" right away with the correct settings, it works.

I have attached two versions of the action. Both don't reduce the number of colors.
This one defaults to PNG with alpha:
ExportWithTransparency.actions
This one defaults to PNG without alpha:
ExportWithoutTransparency.actions
Martin
Du hast keine ausreichende Berechtigung, um die Dateianhänge dieses Beitrags anzusehen.
cadudesun
Mitglied
Beiträge: 19
Registriert: Di 14 Dez 2021 15:36

Re: How to save/export layers and pages as PNG given certain situations...

Beitrag von cadudesun »

Martin Huber hat geschrieben: Mo 20 Dez 2021 11:29 I have attached two versions of the action. Both don't reduce the number of colors.
Thank you very much for sharing the actions.
Happy holidays and an outstanding forthcoming year!