How do I export+import PNG's properly?

Wondering how to accomplish a certain animation task? Ask here.

Moderators: Víctor Paredes, Belgarath, slowtiger

wyrm
Posts: 9
Joined: Sun Aug 19, 2007 4:00 pm

How do I export+import PNG's properly?

Post by wyrm »

I use Corel Painter to make a multi-layered image, export it as a Photoshop file and use the Photoshop-to-Anime Studio script to get the layers into Anime Studio. This results in each layer being exported as a PNG file with alpha channel. I also tried exporting the layers one by one using "Save for Web".

As shown in the image below, even though the PNG file seems to have correct alpha (upper half with checkerboard), I get black artifacts in Anime Studio (lower half; the background is another image layer). Using the "extra-smooth images" export option doesn't make a difference.

Image

The same files import properly into After Effects CS3. What can I do to fix this in Anime Studio (AS Pro 5.5)?
Last edited by wyrm on Mon Aug 20, 2007 3:54 pm, edited 1 time in total.
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Instead of posting a screen grab, post the actual png file. I or someone else could look at it and see if there is a reason for the "black spots".

-vern
wyrm
Posts: 9
Joined: Sun Aug 19, 2007 4:00 pm

Post by wyrm »

Here's the PNG. Hopefully Imageshack didn't modify the file.

To get what I get, put the image as an image layer, then put another image or vector layer containing, for example, a large fill under it.
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

I've done what you said and the artifact appears. Also I've composited with the Gimp the same image over a layer with the same color than the one from AS and the artifact doesn't appear.
It is a bug.
-G
Last edited by Genete on Sun Aug 19, 2007 10:35 pm, edited 2 times in total.
scunge
Posts: 18
Joined: Sat Jun 30, 2007 8:51 am

Post by scunge »

I tried your file and found that if you change the image layers blending mode to something different in Anime Studio that the artifacts disappear or are not as obvious. Color blending mode seems to work.

Image
Image

This may or may not work for what you want to do.

-Mark
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

What I found is that by using levels in photoshop on the transparency of the image those "artifacts" line up exactly with several spots in the transpancy area that are completely "black" or masking 100% of the image with a soft edge around it.

My thought would you could eliminate those spots if the transparency in those spots didn't go to 100% black. I don't know for certain if this is a bug or not. This could have something to do with antialiasing in AS but I'm not sure.

If you put the render and this image side by side the artifacts coincide with those spots on the transparency after pushing the levels all the way to "the left" in photoshop... compressing the histogram to remove any pixel not 100% black.

those artifacts are the ONLY areas inside the image that are 100% "black" or 100% transparent.

Image

-vern
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Some more info on the previous post:

The image posted is 100%. The areas I found in the mask are only 1 pixel high and 1 or more pixels wide.

What this means is that AS is trying anti-alias a 1 pixel area. This small an area is probably causing trouble. Anti-aliasing is usually only one or two pixels to begin with... then you try to anti-alias a one pixel area... it probably gets "confused". ;)

I found when I shrunk the image layer there were no artifacts... maybe the anti-aliasing was enough at that size to hide those dark spots.

I would suggest making the image much larger and shrinking it down in AS to the size needed. This might give AS's anti-aliasing something more to work with. Those areas of 100% transparency inside the image will be larger than one pixel.

-vern
wyrm
Posts: 9
Joined: Sun Aug 19, 2007 4:00 pm

Post by wyrm »

Thanks for the informative replies.

Blending modes work for some images, don't work for others unfortunately (the artifacts disappear but the blending is wrong :)). I'm going to try adjusting the alpha channels in Photoshop and also the resizing suggestion but even if one of those works, it's a lot of work with potentially hundreds of layers. Still, I'd rather not go to After Effects. :)

And perhaps a bug report is in order.
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Woohoo!

Piece of cake.

Just "lighten" the transparency of those spots inside the image area a tiny bit. Just get those black bits inside a little lighter than black. It completely eliminates those dark spots.

I don't know how you use Photoshop but I always create my layers for export to 24 bit png with transparency with a layer mask and save a psd so I can modify it if I need to.

If you've done this just select the INSIDE area (not the whole transparency) and run levels on the mask. I set the first output number to like 1... just enough to lighten the black values a tiny bit so it isn't 100% black.

This new mask works better in AS. I think it is a combination of image size and anti-aliasing in AS.

If you use photoshop I have a link below to a psd.

Image
http://www.lowrestv.com/moho_stuff/foru ... rn-mod.psd

-vern
wyrm
Posts: 9
Joined: Sun Aug 19, 2007 4:00 pm

Post by wyrm »

The layers are made in Corel Painter so when exported to Photoshop they don't get a proper layer mask. But I think I found another solution: Defringe (under the Layer, Matting menu in Photoshop CS). Defringing with a 1-pixel width took care of the artifacts. Now I need to automate applying it to every layer in an image.
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Defringing would do it... but it kind of screws up the edges a bit I think.

Silly me, all you need to do is lower the transparency slightly! Once again just select those inner areas with a feathered selection and lighten it a touch. It will lighten the "whole" area as well but it is such a tiny amount probably not noticeable.

Photoshop has scripting tools and actions so automating it should be simple enough using defringe.

-vern
8 5 0
Posts: 13
Joined: Tue Aug 21, 2007 12:24 am
Location: Atlanta

Post by 8 5 0 »

Here is an explanation: http://www.td-grafik.de/ext/xfrog/alpha/index.html

Anime Studio needs to be able to import images with the option to choose straight alpha or premultiplied alpha just like After Effects does. Here's an excerpt from another article...
Premultiplied versus "Straight" Alpha

As a rule, using alpha channel is by far the easiest way of layering images one over another. The only downside is that there are two ways in which alpha channels can be written to a file: premultiplied and "straight".

Unfortunately, you may well encounter premultiplied alpha as it is the way that Photoshop composites layers of images, whereas most dedicated compositing programs such as After Effects, Combustion and so on are happier with "straight" or non premultiplied alpha.
Put as simply as possible: with premultiplied alpha, the actual colours of a foreground image are blended into the background colour as well as the alpha channel blending from opaque to transparent. In a straight alpha foreground image, the alpha channel still blends from opaque to transparent but the other channels, (the RGB colours), are left untouched.

Ignoring the technical explanation, all you need to know is that if you import an image to layer over another and you get very odd fringing effects where you were expecting a seamless blend, you are using the wrong sort of alpha information. Fortunately, most "high end" programs will quickly convert the image to the right sort. Almost always, you will be trying to use a premultiplied image where a straight one is needed. If it is the other way round, instead of bad fringing, you will get more subtle but unexpected changes in brightness.

Wherever possible, use "straight" alpha where a choice is offered.

Edit:
Well maybe that isn't the explanation exactly. With After Effects, imported PNGs aren't givin the option to have a straight or premultiplied alpha. I think the problem is just with how Anime Studio handles PNG files. Maybe it is a bug. I'm still searching around to find a solution since I need clean PNG images in my animation.

An alternative would be to import Targa files with alphas, but apparently Anime Studio doesn't bring in the alpha with the Targa. :?
User avatar
Touched
Posts: 504
Joined: Mon Dec 11, 2006 7:33 am
Location: Sunny California
Contact:

Post by Touched »

I always premultiply everything when I need to composite with an alpha channel. Usually, I'm premultiplying to black to match the black outlines of my characters, but for a file like this, where it's all a single colour, I just fill the entire main channel with the desired colour, and rely on the alpha channel to handle the shape. That way there's no border colour to mess it up -- if it picks up anything, it'll pick up more of the same colour, and not be noticeable.

Attached a PSD file to illustrate. You see I flattened it to the solid colour. If you export as a PNG and import it in AS, it should work fine.
http://www.drowtales.com/~whiteradish/moho/layer1.zip
8 5 0
Posts: 13
Joined: Tue Aug 21, 2007 12:24 am
Location: Atlanta

Post by 8 5 0 »

The problem is is that PNG doesn't use the alpha channel. It uses transparency. If you flatten the image, there's no transparency, only a solid.

For example... I downloaded your Photoshop file, saved the image as PNG and then imported it into Anime Studio. The imported image was a solid blue rectangle which was the flattened image. The alpha in the PSD file wasn't embedded into the PNG image. This would have worked with a Targa if, like I said before, AS recognized the Targa's alpha channel.
User avatar
Touched
Posts: 504
Joined: Mon Dec 11, 2006 7:33 am
Location: Sunny California
Contact:

Post by Touched »

Holy crap! You're right, it's not being saved properly out of Photoshop in the recent versions! I've been using Photoshop 5.5 forever, and it works in that version, but not in the modern ones. I can't help on that matter, then.
Post Reply