tv_SaveImage and tv_LoadImage with transparent bkgnd

A forum dedicated to George scripting questions
Post Reply
Svengali
Posts: 1553
Joined: 28 Dec 2006, 10:08

tv_SaveImage and tv_LoadImage with transparent bkgnd

Post by Svengali »

I'm trying to save, then load the current image (pixels from current layer only) keeping transparency intact. Instead, I am getting back opaque black pixels where there were originally transparent:

Code: Select all

//(first to save)
tv_SaveMode PNG
tv_SaveImage "test.png"

//(then to load)
tv_LoadImage "test.png"

How do I fix this?

Sven
User avatar
malcooning
Posts: 2114
Joined: 29 Mar 2006, 12:43
Location: Tel Aviv
Contact:

Re: tv_SaveImage and tv_LoadImage with transparent bkgnd

Post by malcooning »

Maybe somehow to force save in RGBA mode?
In similar scripts for other filetypes, he export format (i.e .avi) would draw the settings from the last exported settings. So if you last exported an .avi without alpha, so would the script afterwards save an .avi without alpha.
Svengali
Posts: 1553
Joined: 28 Dec 2006, 10:08

Re: tv_SaveImage and tv_LoadImage with transparent bkgnd

Post by Svengali »

Yes, it might be something like that. I am chasing two similar phantoms and solving one may solve the other too. Thanks.

Sven
User avatar
malcooning
Posts: 2114
Joined: 29 Mar 2006, 12:43
Location: Tel Aviv
Contact:

Re: tv_SaveImage and tv_LoadImage with transparent bkgnd

Post by malcooning »

I have one PNG sequence exporter with alpha enabled. Although it is only an exporter, it does not load back the PNG.
I might be stating the obvious here but I thought of posting it here just in case it might help.
As well, it's a 'current layer' exporter, not display.

Code: Select all

Param none

    path = "path"

    tv_LockDisplay "please wait..."

    Extension = ".png"
    tv_SaveMode "PNG"
    tv_AlphaSaveMode PreMultiply


    tv_LayerCurrentID
    OriginLayer = result

    layerpos = 0
    fini = 0
    DO
      tv_LayerGetID layerpos
      lid = result
      if (CMP(lid,"None")==1)
        fini = 1
      else
        lid[layerpos] = lid
        tv_LayerDisplay lid OFF
        state[layerpos] = result
        tv_LayerInfo lid
        parse result dis pos opacity name rest
        name[layerpos] = name
      end
    layerpos = layerpos+1
    UNTIL fini
    nblayer = layerpos-2

    tv_GetWidth
    w = result
    tv_GetHeight
    h = result


    FOR layerpos = 0 TO nblayer

      message = "Process layer "
      message = concat(message,layerpos+1)
      message = concat(message,"/")
      message = concat(message,nblayer+1)
      tv_LockDisplay message

      tv_LayerSet lid[layerpos]
      filename = concat(path,name[layerPos])
      filename = concat(filename,"__(L"(layerpos+1)".F1)")
      filename = concat(filename,Extension)
      tv_LayerSelect -100000 200000
      tv_Brushcut 0 0 w h 0 1
      tv_SaveBrushAnim ""filename""
    END

    FOR layerpos = 0 TO nblayer
    tv_LayerDisplay lid[layerpos] state[layerpos]
    END

    tv_LayerSet OriginLayer
    tv_UnLockDisplay
Svengali
Posts: 1553
Joined: 28 Dec 2006, 10:08

Re: tv_SaveImage and tv_LoadImage with transparent bkgnd

Post by Svengali »

Thanks Asaf!
I was missing the tv_AlphaSaveMode PreMultiply command... (which I've used before in several old scripts, but forgot about)
SaveAndLoadTestImage.jpg
SaveAndLoadTestImage.jpg (16.78 KiB) Viewed 696 times
and that might solve the other problem as well. 8)

Sven
Edit: Yes, that solved the other problem too! again, thank you.
User avatar
malcooning
Posts: 2114
Joined: 29 Mar 2006, 12:43
Location: Tel Aviv
Contact:

Re: tv_SaveImage and tv_LoadImage with transparent bkgnd

Post by malcooning »

Svengali wrote:Thanks Asaf!
I was missing the tv_AlphaSaveMode PreMultiply command... (which I've used before in several old scripts, but forgot about)
SaveAndLoadTestImage.jpg
and that might solve the other problem as well. 8)

Sven
Edit: Yes, that solved the other problem too! again, thank you.
8)
I'm glad to have this rare opportunity to help you with scripts, considering I'm absolutely no good at it!
Post Reply