Way to produce a transparent canvas?

Ask for help and post your question on how to use XnView Classic.

Moderators: XnTriq, helmut, xnview

cday
XnThusiast
Posts: 3891
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Way to produce a transparent canvas?

Post by cday »

Is it possible to produce a file consisting solely of a transparent blank canvas? [PNG]

I'd like to produce a transparent canvas on which I can later place shapes, and transparency isn't one of my special subjects... :wink:


An alternative, if that isn't straightforward, would be the simplest steps to make the white background in the attached image completely transparent.

Example.png
You do not have the required permissions to view the files attached to this post.
User avatar
XnTriq
Moderator & Librarian
Posts: 6259
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Way to produce a transparent canvas?

Post by XnTriq »

cday wrote:An alternative, if that isn't straightforward, would be the simplest steps to make the white background in the attached image completely transparent.
There are actually four ways of achieving this, two of which can be done in XnView:
  1. truecolor + alpha channel
    1. Open Example.png in the viewer/editor.
    2. Increase the color depth with Image » 32 bits.
    3. Select the white area above the blue square and hit Del on your keyboard (= Edit » Clear).
    4. Repeat step #3 with the white areas below and next to the blue square.
  2. indexed/palette-based + single-color transparency
    1. Open Example.png in the viewer/editor.
    2. Go to File » Export... » PNG.
    3. Since your image has only 2 unique colors, you can select 8 colours (Adaptive) in the drop-down list next to Color mode.
    4. The Set transparency color... button takes you to the Edit palette dialog.
    5. Activate the Enable transparency checkbox.
    6. Select the fist entry (white) in the palette.
  3. truecolor + single-color transparency
  4. indexed/palette-based + alpha channel
cday
XnThusiast
Posts: 3891
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Way to produce a transparent canvas?

Post by cday »

Thank you very much, I know transparency is one of your special subjects... :wink:

It will probably be tomorrow before I test now, but there is no way direct to create a freestanding blank transparent canvas, presumably?

In Method #1 the white areas are in effect deleted if I understand correctly, which would require four precise selections, which would make Method #2 the more precise method?
User avatar
XnTriq
Moderator & Librarian
Posts: 6259
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Way to produce a transparent canvas?

Post by XnTriq »

cday wrote:[…] but there is no way direct to create a blank transparent canvas, presumably?
  1. Open any image file.
  2. Resize it to the dimensions you require.
  3. Increase the color depth with Image » 32 bits.
  4. Edit » Select All (Ctrl+A)
  5. Edit » Clear (Del)
A File » New... command for creating a blank canvas has been requested in the past.
cday wrote:In Method #1 the white areas are in effect deleted if I understand correctly, which would require four precise selections, which would make Method #2 the more precise method?
Exactly. Because XnView isn't meant to be a full–fledged image editor, it only has a basic rectangular Marquee tool for cropping and is lacking a Magic Wand (for selecting areas of same/similar color) or Lasso (for creating freeform selections).

Image
cday
XnThusiast
Posts: 3891
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Way to produce a transparent canvas?

Post by cday »

Thanks again, I'll try all those methods tomorrow... :D

[Edit: you might like this thread: https://www.diybookscanner.org/forum/vi ... 236#p20235
Maybe you have a better solution to the originating problem in the first post of the thread? :wink: ]
User avatar
XnTriq
Moderator & Librarian
Posts: 6259
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Way to produce a transparent canvas?

Post by XnTriq »

p135768.zip
Contents of attachment:
  • 0_Example.png
    1_XnView_Truecolor+Alpha.png
    1_FireWorks_Truecolor+Alpha.png
    1_SuperPNG_Truecolor+Alpha.png
    2_XnView_Palette+Index.png
    2_FireWorks_Palette+Index.png
    2_PNGOptimizer_Palette+Index.png
    3_TweakPNG_Truecolor+tRNS.png (Ignored by XnView)
    4_FireWorks_Palette+Alpha.png (Supported by XnView since v1.97)
cday wrote:you might like this thread: https://www.diybookscanner.org/forum/vi ... 236#p20235
Maybe you have a better solution to the originating problem in the first post of the thread? :wink:
Will do :mrgreen:
You do not have the required permissions to view the files attached to this post.
cday
XnThusiast
Posts: 3891
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Way to produce a transparent canvas?

Post by cday »

A blank transparent canvas may be unusual, but I was interested in producing one because I had in mind producing a number of transparent masks with opaque shapes positioned on them, and starting with a blank canvas would be slightly quicker [and more elegant... ] than starting with a white canvas and then converting each one to be transparent.

I successfully produced a blank transparent canvas using the method in your second post (which might have been labelled as method #5) and as expected it displays as a checker-board in XnView MP, although in XnView Classic and another popular image editor the viewer window appears blank, although it is possible to paste shapes onto the presumed position of the canvas and save the result.

However, the watermark action in XnConvert [and also XnView Classic] fails to produce the expected result on the transparent canvas file, having no visible effect...

I don't know whether there is a fundamental reason for that, whether it can be considered as a bug, or whether it is simply a case that perhaps understandably wasn't considered when the software was designed??

Transparent_canvas.zip
You do not have the required permissions to view the files attached to this post.