Photoshop: edge artifacts on rasterization of some PDF files

  • 1
  • Problem
  • Updated 3 years ago
  • (Edited)
I noticed and after some research i discovered issue during opening pdf files.it is quite complex issue which happen on transparent bitmaps included in pdf.
The problem are black artefacts around transparent graphics.
What i discovered is. that CS5 was last version doing it right. CS6 have terrible results CC is doing almost fine but here and there are still one or two black spots on borders.
It is cause by separate transformation of DATA stream and Transparency stream.
Workaround is to include bleeded data into pdf. 
The same pdf was loaded with same settings into different photoshop versions.CS5 is clean and beautiful
CS6 you can see how bad it went
CC - can you see that little black pixel? (well its still there and its on more places around border.

You can even see the scaling algorithm allowed CS5 to draw complete (R) symbol.
CS6 and CC are another scaling type which leads in jugged edges


I suggest that adobe take the source picture packed in pdf, join the data stream with transparency and then apply all transformations needed to draw it - the same way as it is doing on layers.

You probably know that pixel with 0 alpha should have 0 effect to its neighbourhood pixel's colour during transformation(like scale). And all other pixels can be un-premultiplied to its original colour.

This all problem is easily simulated by creating premultiplied layer with layer mask and then try to free transform the layer. Pixels of layer are then not affected by the mask, which is leading to mixture of colours, after it is masked with layer mask the dark border appears...
--------------
Second part of the problem is, that even vector shapes are read from PDF as premultiplied layers. Which after direct saving to PNG you can find when you remove alpha(using gimp).
Well i know much more about this issue now. Just i would like to have more detailed talk with somebody from adobe.
Photo of bobo

bobo

  • 18 Posts
  • 0 Reply Likes
  • like i am dealing with amateurs.

Posted 3 years ago

  • 1
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 818 Reply Likes
Photoshop CS5 had terrible (and slow) antialiasing for rasterizing vector files.
Photoshop CS6 switched to a better (and faster) antialiasing method, but exposed some bugs in the rasterization engine that had to be fixed in the next few releases.

The image transparency stays with the image color data, always.  They cannot be transformed separately unless they were written into the PDF as separate operations (ie: image + another mask layer).

And there shouldn't be any premultiplied color involved at all.

We would need to see the exact file that produced these artifacts, in order to figure out exactly what caused the artifacts.
Photo of bobo

bobo

  • 18 Posts
  • 0 Reply Likes
where can i send it to you?
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 815 Reply Likes
ccox (at) adobe (dot) com
Photo of bobo

bobo

  • 18 Posts
  • 0 Reply Likes
we are t-shirt printing company with online creator, we cannot affect what users uploads to us. Mostly all transparent images which they send are premultiplied.. 
We then generate pdf where the file is placed to exact location as it should be printed. 
So the data are premultiplied, and we are now working on bleeding algorithm to fix this.--------------------------But this issue is much more about the fact that same file is opened in different versions with different results.
Even when the source data in pdf are correct.That mean that setting the radio-button to "images" in pdf opening dialog is allowing me to extract the graphics in its original resolution, this opened image i am able to transform in photoshop without artefacts.
That really seems to me that after opening the transparency is joined with the layer and therefor transformed properly.
But during opening of pdf it looks to me like transformation of data + mask
-------------------------
Next is the scaling algorithm itself.. why do i have that terrible (R) representation in CC and CS6 when cs5 (even slower maybe) is doing nice job.
--------------------------

Another thing i noticed is that when i use this picture in illustrator and zoom it just by loupe when graphic acceleration is turned on, i am able to see the artefacts already in the stage.
This is not happening with software rendering.
-----------------------
Do you use graphic card to open pdf?
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 815 Reply Likes
No, the GPU is not used to rasterize PDF in Photoshop.
But it may be used in Illustrator, depending on your preferences in Illustrator.
Photo of bobo

bobo

  • 18 Posts
  • 0 Reply Likes
And regarding vector rasterisationjust do this please:
open illustrator, create there colour circle, save it as pdf.open this pdf in photoshop and just save it as png.get to gimp - or any other software which removes alpha.and you can see its premultiplied. 

I know that normally photoshop is doing bleeding during saving of png (btw also not the best algorithm) but this is not applied just after rasterising pdf.
If you transform this opened layer and save to png then it gets bleed.
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 818 Reply Likes
Photoshop does not use premultiplied data unless the file format calls for it.
And PNG does not use premultiplication - so Photoshop won't do any premultiplication when saving to PNG (and we'd have a lot of people on our case if we did).
I think all you're seeing is the data behind the transparency in your image -- which is undefined and can depend on the image history (filters, resizing, etc.).
Photo of bobo

bobo

  • 18 Posts
  • 0 Reply Likes
Putting the transparent graphic to black background is makeing the same result as if you premultiply it. So we are talking about both, black matte and premultiply.
if you have green semitransparent pixel on black background you get 0,128,0,0.5if you have the same green pixel and you premultiply it you get 0,128,0,0.5
Photo of bobo

bobo

  • 18 Posts
  • 0 Reply Likes
But you are right. photohsop dont premultiply! yes it is keeping the colour which was there for example before applying mask.
I agree. also on graphics created in photoshop - with undefined pixels. it even apply bleeding during png save so thats correct.
BUT - during vector rasterisation - thats what are my screenshots about. it is able to read green circle and save it directly with exactly the black background. - not bleeding, not undefined, just black. as you can see
Photo of bobo

bobo

  • 18 Posts
  • 0 Reply Likes
this just mean you cannot use photoshop to read pdf created in illustrator and save it as png properly.. which means that even on such file after reusing it, the artefacts would happen.
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 818 Reply Likes
Yes, you can use Photoshop to rasterize vector artwork and save it as raster - that is done all the time.
You seem to be confusing several issues, and jumping to incorrect conclusions.
Photo of bobo

bobo

  • 18 Posts
  • 0 Reply Likes
vector rasterisation i uploaded pdf and few screenshots here Download
artefacts - i uploaded the pdf here - Download
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 815 Reply Likes
I'm not seeing the black edge artifacts you showed in Photoshop CC.

The only artifacts I can see when the image is rasterized in Photoshop are some hairlines due to abutting shapes (two shapes side by side won't rasterize as solid if you have any kind of antialiasing enabled).  And those are expected if you have antialiasing enabled (it's a mistake in the way the vector file was created).
Photo of bobo

bobo

  • 18 Posts
  • 0 Reply Likes
well the data in pdf (transformer) are bitmap not vector. this bitmap we received from our client. in its untransformed way which you can extract from pdf it is nice bitmap opened and transformed correctly in photoshop.
When you open it as this pdf lets say at 300dpi with media box as setting and just put some white background layer under it. i am sure you will see it.
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 815 Reply Likes
See what?  What artifacts are you seeing (other than the expected antialiased abutting edges)?