News for hackers. Stuff that matters.
Re:Fun Photoshop File Format Facts by IvanK_net on Thursday March 03, 2016 @12:28PM (#11218342)
BTW. I have spent 3 years studying PSD format while making http://www.photopea.com

True fun facts are, that Adobe specification http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/ is very incomplete and that Adobe is not going to make some data open https://forums.adobe.com/thread/1524517 .

You can ask me questions, if you want :)

Re:Fun Photoshop File Format Facts by agumonkey on Thursday March 03, 2016 @12:47PM (#11218484)
reminds me of the CCC PDF talk https://www.youtube.com/watch?v=l6eaiBIQH8k

lots of .. surprises.

Re:Fun Photoshop File Format Facts by IvanK_net on Friday March 04, 2016 @03:06PM (#11226521)
PDFs can be inserted into PSD file as a smart object. So we will need to add PDF support into Photopea in the future. Luckily, there already exists pdf.js https://github.com/mozilla/pdf.js/ :)
Re:Fun Photoshop File Format Facts by santa_boy on Thursday March 03, 2016 @09:43PM (#11221722)
@IvanK_net ... Photoshop is so developer unfriendly ... but now by exposing generators, it seems to be improving a bit (like shown here https://www.youtube.com/watch?v=wHqgUvw5mno)

I need to a super simple task of replacing the image in a Smart Object without having to go through the entire UI thing. Any idea if such a thing is possible?

Re:Fun Photoshop File Format Facts by IvanK_net on Friday March 04, 2016 @04:47AM (#11222860)
I don't know if it is possible in Photoshop, but Photopea has a very good support of Smart Objects since the last release. Such thing would take me like extra 15 lines of code.

Do you need to edit your own PSDs, or you want it to be done automatically in your app?

Re:Fun Photoshop File Format Facts by santa_boy on Friday March 04, 2016 @04:56AM (#11222880)
@IvaK_net: The use case is as follows. I have standard PSDs with smart objects for various screen sizes.

I want to show various screens on the same template. Currently, I take the screenshot and replace the images one by one.

Ideally, I would like to issue a command from my terminal to use the screenshots (which I generate from another tool) in a folder and pop them into the smartobject and export the output to an output folder.

Re:Fun Photoshop File Format Facts by IvanK_net on Friday March 04, 2016 @05:26AM (#11222928)
I am still not sure if I understand what you need.

If you have a Smart Object, which occurs multiple times in your PSD, you can double-click it, put all your screenshots inside it and save it. Then you can simply switch the visibility of layers inside a smart object.

Using Photopea would require running it in a browser window, it would be hard to connect it with your terminal.

Re:Fun Photoshop File Format Facts by santa_boy on Thursday March 03, 2016 @09:49PM (#11221749)
Wow! What a cool site [Photopea](http://www.photopea.com/) is!
Re:Fun Photoshop File Format Facts by robbrulinski on Friday March 04, 2016 @09:57AM (#11224099)
Does Photopea support automated scripts? Thank you!
Re:Fun Photoshop File Format Facts by IvanK_net on Friday March 04, 2016 @03:03PM (#11226504)
Hi, not yet. But we definitely want to add some scripting in the future.
Re:Fun Photoshop File Format Facts by slr555 on Thursday March 03, 2016 @04:40PM (#11220258)
What is interesting to me is the intersection of all these perspectives about code and the user experience. I have taken quite a few photoshop classes through the years from the perspective of a photographer (as opposed to designer) and what always makes me smile are all the functions you are told never to use. The most basic of these is the menu choice under Image>Black & White. When asked why we should not use it the instructor invariably says, "Photoshop is a monolith of code and Adobe is terrified to remove anything for fear it will all come crashing down. So even though no one uses Black & White it will be there forever."

I am told this is much of the reason that Lightroom was born. It was an effort to make a photographers tool that wasn't crushed under the weight of its own legacy code.

Re:Fun Photoshop File Format Facts by vladdanilov on Thursday March 03, 2016 @02:18PM (#11219229)
The fun is multiplied by how Photoshop actually renders graphics. For example, 1-pixel drop shadow looks identical to 2-pixel one. When scripting, bounds of vector shapes may be off by 1 or 2 pixels due to some floating point math followed by rounding. Just today stumbled across dithering issues caused by mismatching user-defined and internal color values (https://twitter.com/vmdanilov/status/705262877805039616).
Re:Fun Photoshop File Format Facts by PeCaN on Thursday March 03, 2016 @03:49PM (#11219933)
And there's the fact that its rendering of 1px vector rectangle borders depends on their location. Yup, sometimes they render a little bit thicker[1], which can be fixed by moving it up or down a couple pixels. I kind of hate Photoshop, except it's actually 10x better than anything else at what it does[2]. RIP Fireworks though.

(As of CS 5.5)

1. Photoshop does antialiasing/subpixel rendering on vector shapes, so while "a little bit thicker" is of course 2px, the second row of pixels is blended with what's nearby.

2. Haven't tried GIMP for a couple years though. Also I've switched to Krita for digital painting lately, and actually like it more than PS.

Re:Fun Photoshop File Format Facts by emehrkay on Thursday March 03, 2016 @11:19AM (#11217818)
Apparently adding a solid white layer as the upper-most layer will sometimes reduce overall file size.
Re:Fun Photoshop File Format Facts by IvanK_net on Thursday March 03, 2016 @01:29PM (#11218795)
Exactly. There is a flattened RGBA image at the end of a PSD file, which has dimensions corresponding to dimensions of a project.

Reading that flattened image from PSD takes 20 lines of code, while reading the structured content and producing final composition (blend modes, layer styles, masks, adjustment layers ...) takes at least 20 000 lines of code.

Row length encoding is used for storing channel data by default, so area with a constant color can be compressed much more efficiently, than area which has more "noisy" content.

Re:Fun Photoshop File Format Facts by Kequc on Thursday March 03, 2016 @11:26AM (#11217869)
If you're using psd filesize probably isn't your first priority.
Re:Fun Photoshop File Format Facts by Rumudiez on Thursday March 03, 2016 @12:38PM (#11218414)
I believe that's because it saves bytes when generating a flattened preview image which for high resolution PSDs can be quite expensive to do losslessly. Can anybody confirm?
Re:Fun Photoshop File Format Facts by MontagFTB on Thursday March 03, 2016 @01:09PM (#11218648)
This is likely what is going on. PSDs have a flattened, full-size version of the image embedded for compatibility's sake.

Instead of a white top-layer you could also disable the "Maximize compatibility" option when saving the PSD, which will strip out this full size rendition.

Re:Fun Photoshop File Format Facts by jzwinck on Thursday March 03, 2016 @02:36PM (#11219388)
If you disable Maximize Compatibility you also lose compatibility with current programs from Adobe itself, such as Lightroom. So while it seems like a good thing to turn off old crufty stuff, it actually is horrible.
Re:Fun Photoshop File Format Facts by Rumudiez on Thursday March 03, 2016 @02:43PM (#11219444)
I didn't know that Lightroom had that restriction, actually. Is that tested with CC 2015 versions of both programs?

I do know that Maximize Compatibility doesn't affect usage within Illustrator and InDesign documents, though, which to me are the more common use cases for a PSD anyway, so I'll probably stick to unticking that box.

Re:Fun Photoshop File Format Facts by feiss on Thursday March 03, 2016 @04:49PM (#11220329)
Or putting all layers inside a not visible group. Nothing to save (or it's very well compressed) in the flatenned preview. In large files it's a big save
Re:Fun Photoshop File Format Facts by Archio on Thursday March 03, 2016 @01:09PM (#11218651)
This gives me fond memories of the famous PSD format rant in source code: http://codepad.org/DidDsbjF
Re:Fun Photoshop File Format Facts by jkaptur on Thursday March 03, 2016 @01:17PM (#11218712)
Maybe it was the article's reprinting of that rant, in its entirety, with a link to the actual file in github.
Re:Fun Photoshop File Format Facts by logicrook on Thursday March 03, 2016 @01:46PM (#11218939)
Hey, do we have to read the articles before commenting now?

Let's take a stand for free speech! Ill, unadvised speech is still speech!

Re:Fun Photoshop File Format Facts by draw_down on Friday March 04, 2016 @08:30AM (#11223552)
Seriously?