Re: Extracting previews from PSB files with ImageMagick/StaticSync

1,472 views
Skip to first unread message

Tom Gleason

unread,
Jul 23, 2012, 9:49:39 PM7/23/12
to resour...@googlegroups.com
Special preview handling is done in include/preview_preprocessing.php. It handles unique methods of generating a preview base image for different file formats. 

On Mon, Jul 23, 2012 at 9:39 PM, Electric Art <em...@electricart.com.au> wrote:
Hi there,

We have a ResourceSpace library that we have setup that uses StaticSync to create previews/thumbnails of resources.

Currently running Ubuntu 11.04 Server, using ImageMagick 6.6.0-4.

We are using ImageMagick as we need to support PSB files. We are having a problem though, in that ImageMagick chews up all the RAM allocated to the server within seconds of trying to generate a preview for a PSB file, and eventually, an hour or more later, results in a blank white preview (if at all). Even our smallest PSB files (just over 2GB) are a problem, and we have PSB files as big as 11GB! After looking into the ImageMagick forums/documentation, it seems it is possible to tell ImageMagick to extract the preview layer that Photoshop generates (Photoshop saves a flattened copy of the file in PSD and PSB files if you tell it to save with compatibility for previous versions) by telling it to extract layer [0] and work with that instead. Is there a way I can configure ResourceSpace/StaticSync so that, for PSB files only, so that it tries to extract the preview layer instead of trying to generate it's own composite of the PSB (which it seems to fail at and take forever to do).

So, for example, by adding [0] after the filename with the convert command, we can extract the Photoshop flattened version (which I assume will save time/processing power and hopefully give us something useful!);

convert boots.psd[0] -thumbnail 340x340 boots_png.png

How would I go about implementing this in ResourceSpace? I can't seem to find the code where I would try this? Should I be looking in the delegates file for ImageMagick? I couldn't seem to find PSB in there, but is that because PSD and PSB files are treated the same?

Any help on this matter would be greatly appreciated!

kind regards,
Tristan.

--
You received this message because you are subscribed to the Google Groups "ResourceSpace" group.
To view this discussion on the web visit https://groups.google.com/d/msg/resourcespace/-/bmg2H13M9asJ.
To post to this group, send email to resour...@googlegroups.com.
To unsubscribe from this group, send email to resourcespac...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/resourcespace?hl=en.



--
Tom Gleason
ResourceSpace Hosting & Development

Vice President, Engineering
Colorhythm LLC
http://www.colorhythm.com

Main Office:  +1 415-399-9921
Fax: +1 253-399-9928
Mobile:  +1 347-537-8465

tgle...@colorhythm.com

Stefan Wild

unread,
Jul 24, 2012, 11:13:03 AM7/24/12
to resour...@googlegroups.com
In config.php try setting $photoshop_thumb_extract=true;
Then you will need to change include/preview_processing.php around line 168 from
if ($extension=="psd" && !isset($newfile))
to
if (($extension=="psd" || $extension=="psb") && !isset($newfile))

If that works I guess we should be changing that in the core (and look for other occasions of "psd" and add "psb" there, too).

Regards,
Stefan

--
ResourceSpace hosting

Electric Art

unread,
Jul 24, 2012, 9:45:14 PM7/24/12
to resour...@googlegroups.com
Hi Stefan,

Thanks so much for the reply. A question though - is the Photoshop thumbnail the same as the composite layer? I'm not sure that it is? There's an option to save an icon/thumbnail in Photoshop but it's not the same as saving with 'compatibility' for previous versions, which is the option that saves a flattened copy of the image in the PSD/PSB as layer [0] (which ImageMagick can supposedly then extract). I'll try your suggestion though and see what comes out of it. I was finding it hard to find documentation on exiftool that refers to this? (That part of the code you referred me to seems to use exiftool and not ImageMagick)...

Anyway I'll try the thumbnail code and see how I go.

Thanks again!

kind regards,
Tristan.

Electric Art

unread,
Jul 24, 2012, 9:50:41 PM7/24/12
to resour...@googlegroups.com
Ok so just tried it. It extracts the icon/thumbnail great. Unfortunately it is only the thumbnail generated by Photoshop, so it's tiny, and as such, it doesn't generate any of the other sizes.

I know almost nothing about php coding, but I might have a go at trying to piece together some code to add [0] to the convert command of imagemagick just for PSD/PSB files....

Thanks again for your help!

Tristan.

On Wednesday, 25 July 2012 01:13:03 UTC+10, Stefan Wild wrote:

Jeff Harmon

unread,
Jul 24, 2012, 10:58:14 PM7/24/12
to resour...@googlegroups.com, resour...@googlegroups.com
In your preferences in Photoshop, what have you checked for previews?

I bet this will be your ticket to joy. 

J

--
Jeff Harmon
Chief Executive Officer
--
You received this message because you are subscribed to the Google Groups "ResourceSpace" group.
To view this discussion on the web visit https://groups.google.com/d/msg/resourcespace/-/zor_7cD9fMsJ.

Electric Art

unread,
Jul 25, 2012, 12:23:40 AM7/25/12
to resour...@googlegroups.com
Hi Jeff,

Icons for MacOS and Windows thumbnails are checked, however there doesn't appear to be any options for sizing of icons/thumbnails generated? The option for 'Maximize PSD and PSB File Compatibility:' is the one that generates a flattened copy which it stores in the PSD/PSB.



I've tried to make some code for the preview_preprocessing.php to add the needed [0] to the convert command line arguments, however I'm working fairly blindly as I don't know php. All I really need to do is have ResourceSpace add [0] after the filename if the file is a PSB for whatever convert command ResourceSpace would normally use to generate the previews/thumbnails. I tried this;

/* ----------------------------------------
        Try PhotoshopCompositeExtract
   ----------------------------------------
*/
# Note: to work, Photoshop files must be saved with Compatibility on. For PSB support, ImageMagick must be installed.
if ($extension=="psb" && !isset($newfile))
        {
        global $photoshop_composite_extract;
        if ($photoshop_composite_extract)
                {
                if ($convert_fullpath!=false)
                        {
                        run_command($convert_fullpath . ' '. escapeshellarg($file) .'[0] '.' > '.$target);
                        }
                if (file_exists($target))
                        {
                        #if the file contains an image, use it; if it's blank, it needs to be erased because it will cause an error in ffmpeg_processing.php
                        if (filesize_unlimited($target)>0){$newfile = $target;}else{unlink($target);}
                        }
                }
        }

And added;

$photoshop_composite_extract=true;

to config.php

But it gives me this as a result;

convert: Not a JPEG file: starts with 0x56 0x65 `/var/www/resourcespace/include/../filestore/7/1/5/6/4_c9436a3dab9555d/71564_d7f89d6d5184896.jpg' @ error/jpeg.c/EmitMessage/233.
convert: missing an image filename `/var/www/resourcespace/include/../filestore/7/1/5/6/4_c9436a3dab9555d/71564col_7c145430402b354.jpg' @ error/convert.c/ConvertImageCommand/2940.

Obviously I'm doing something wrong as it's making a file, and calling it .jpg when it obviously isn't. I'm going to work at it further and see if I can make it happen. I'm also worried that by making the preview this way I'm going to bypass all the colour profile stuff, which is important to us (we need to preserve colour profiles, then convert so that the correct colour is generated for previews)....

Any help would be greatly appreciated!

thanks,
Tristan.
To unsubscribe from this group, send email to resourcespace+unsubscribe@googlegroups.com.

Jeff Harmon

unread,
Jul 25, 2012, 1:21:26 AM7/25/12
to resour...@googlegroups.com, resour...@googlegroups.com
What version of Photoshop is this?

J

--
Jeff Harmon
Chief Executive Officer
Colorhythm LLC

Main Office:  +1 415-399-9921
Mobile:  +1 510-710-9590

To view this discussion on the web visit https://groups.google.com/d/msg/resourcespace/-/I6jP2t6LEpoJ.

To post to this group, send email to resour...@googlegroups.com.
To unsubscribe from this group, send email to resourcespac...@googlegroups.com.

Electric Art

unread,
Jul 25, 2012, 2:20:48 AM7/25/12
to resour...@googlegroups.com
Hi Jeff,

It's CS5.

I personally don't remember there ever being settings for Icon/Thumbnail size... but then again, I was never really looking for it!

regards,
Tristan.

Jeff Harmon

unread,
Jul 25, 2012, 2:25:02 AM7/25/12
to resour...@googlegroups.com, resour...@googlegroups.com


--
Jeff Harmon
Chief Executive Officer
Colorhythm LLC

Main Office:  +1 415-399-9921
Mobile:  +1 510-710-9590

To view this discussion on the web visit https://groups.google.com/d/msg/resourcespace/-/I6jP2t6LEpoJ.

To post to this group, send email to resour...@googlegroups.com.
To unsubscribe from this group, send email to resourcespac...@googlegroups.com.

Electric Art

unread,
Jul 25, 2012, 3:47:19 AM7/25/12
to resour...@googlegroups.com
Hi Jeff,

I can't find that option in saving any file format that I tried under MacOS. Must be a legacy option. It also seems like it was mainly an option for EPS files (from the wording they use)...?

kind regards,
Tristan.

David Mac (new)

unread,
Jul 25, 2012, 4:32:18 AM7/25/12
to ResourceSpace
Hi All

Something strange appears to be going on. I have psd files in my test
system that have previews.
But, I've updated to the latest version, and now I can't generate any
previews for either psd or psb files.
I've tested single layer and multi layer files from CS5 and CS6 and I
get the same problem, no previews.

Error log shows:
dyld: Library not loaded: /System/Library/Frameworks/OpenCL.framework/
Versions/A/Libraries/libclparser.dylib
Referenced from: /opt/local/bin/identify
Reason: image not found
dyld: Library not loaded: /System/Library/Frameworks/OpenCL.framework/
Versions/A/Libraries/libclparser.dylib
Referenced from: /opt/local/bin/convert
Reason: image not found
dyld: Library not loaded: /System/Library/Frameworks/OpenCL.framework/
Versions/A/Libraries/libclparser.dylib
Referenced from: /opt/local/bin/convert
Reason: image not found
dyld: Library not loaded: /System/Library/Frameworks/OpenCL.framework/
Versions/A/Libraries/libclparser.dylib
Referenced from: /opt/local/bin/convert
Reason: image not found
dyld: Library not loaded: /System/Library/Frameworks/OpenCL.framework/
Versions/A/Libraries/libclparser.dylib
Referenced from: /opt/local/bin/convert
Reason: image not found
dyld: Library not loaded: /System/Library/Frameworks/OpenCL.framework/
Versions/A/Libraries/libclparser.dylib
Referenced from: /opt/local/bin/convert
Reason: image not found
[Wed Jul 25 09:25:21 2012] [error] [client 127.0.0.1] File does not
exist: /Library/WebServer/Documents/rs/filestore/
1/2/5_7cfa25404788057/125pre_2140185b396f35b.jpg, referer:
http://rs.demo/rs/pages/tools/update_previews.php?ref=125&only=true

and from static sync:
Collection Photoshop Test, theme=Photoshop Testdyld: Library not
loaded: /System/Library/Frameworks/OpenCL.framework/Versions/A/
Libraries/libclparser.dylib
Referenced from: /opt/local/bin/identify
Reason: image not found
dyld: Library not loaded: /System/Library/Frameworks/OpenCL.framework/
Versions/A/Libraries/libclparser.dylib
Referenced from: /opt/local/bin/convert
Reason: image not found
dyld: Library not loaded: /System/Library/Frameworks/OpenCL.framework/
Versions/A/Libraries/libclparser.dylib
Referenced from: /opt/local/bin/convert
Reason: image not found
dyld: Library not loaded: /System/Library/Frameworks/OpenCL.framework/
Versions/A/Libraries/libclparser.dylib
Referenced from: /opt/local/bin/convert
Reason: image not found
dyld: Library not loaded: /System/Library/Frameworks/OpenCL.framework/
Versions/A/Libraries/libclparser.dylib
Referenced from: /opt/local/bin/convert
Reason: image not found
dyld: Library not loaded: /System/Library/Frameworks/OpenCL.framework/
Versions/A/Libraries/libclparser.dylib
Referenced from: /opt/local/bin/convert
Reason: image not found

I've also tried using qlpreview, but that fails.

I'll be doing some more testing later today.
On Jul 25, 8:47 am, Electric Art <em...@electricart.com.au> wrote:
> Hi Jeff,
>
> I can't find that option in saving any file format that I tried under
> MacOS. Must be a legacy option. It also seems like it was mainly an option
> for EPS files (from the wording they use)...?
>
> kind regards,
> Tristan.
>
>
>
>
>
>
>
> On Wednesday, 25 July 2012 16:25:02 UTC+10, Jeff Harmon wrote:
>
> > Actually, I was thinking of a Mac OS-specific option for full-size
> > previews:
>
> >http://help.adobe.com/en_US/photoshop/cs/using/WSfd1234e1c4b69f30ea53...
>
> > Jeff
>
> > --
> > Jeff Harmon
> > Chief Executive Officer
> > Colorhythm LLC
> >http://www.colorhythm.com
>
> > Main Office:  +1 415-399-9921
> > Fax: +1 253-399-9928
> > Mobile:  +1 510-710-9590
>
> > jhar...@colorhythm.com
>
> > On Jul 24, 2012, at 9:23 PM, Electric Art <em...@electricart.com.au>
> > wrote:
>
> > Hi Jeff,
>
> > Icons for MacOS and Windows thumbnails are checked, however there doesn't
> > appear to be any options for sizing of icons/thumbnails generated? The
> > option for 'Maximize PSD and PSB File Compatibility:' is the one that
> > generates a flattened copy which it stores in the PSD/PSB.
>
> > <https://lh6.googleusercontent.com/-jhEEYUM9Ixo/UA90UtQw61I/AAAAAAAAAA...>
> >>> In *config.php* try setting *$photoshop_thumb_extract=true;*
> >>> Then you will need to change *include/preview_processing.php* around
> >>> line 168 from
> >>> *if ($extension=="psd" && !isset($newfile))*
> >>> to
> >>> *if (($extension=="psd" || $extension=="psb") && !isset($newfile))*
>
> >>> If that works I guess we should be changing that in the core (and look
> >>> for other occasions of "psd" and add "psb" there, too).
>
> >>> Regards,
> >>> Stefan
>
> >>> --
> >>>www.archivedi.com
> >>> ResourceSpace hosting
>
> >>  --
> >> You received this message because you are subscribed to the Google Groups
> >> "ResourceSpace" group.
> >> To view this discussion on the web visit
> >>https://groups.google.com/d/msg/resourcespace/-/zor_7cD9fMsJ.
> >> To post to this group, send email to resour...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> resourcespac...@googlegroups.com.
> >> For more options, visit this group at
> >>http://groups.google.com/group/resourcespace?hl=en.
>
> >>  --
> > You received this message because you are subscribed to the Google Groups
> > "ResourceSpace" group.
> > To view this discussion on the web visit
> >https://groups.google.com/d/msg/resourcespace/-/I6jP2t6LEpoJ.
> > To post to this group, send email to resour...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > resourcespac...@googlegroups.com.

Electric Art

unread,
Jul 25, 2012, 4:33:57 AM7/25/12
to resour...@googlegroups.com
Hey Jeff,

Here's the documentation regarding Maximise compatibility for PSD and PSB files;


My thinking is that ResourceSpace could potentially use this flattened copy instead of getting ImageMagick to try to re-composite the whole PSD/PSB if it doesn't have to (and potentially avoid ImageMagick oddities in it's attempt to flatten). This may also make compatibility with future versions of PSD/PSB better, as the flattened layer inside the PSD/PSB will already have any new adjustment layers / special layer types flattened into a single image layer by Photoshop....

Will keep working on the code but haven't gotten any further yet unfortunately.

thanks for all your help so far!

Tristan.

On Wednesday, 25 July 2012 16:25:02 UTC+10, Jeff Harmon wrote:

Adi Prasetya - Pratama

unread,
Feb 10, 2014, 6:43:10 PM2/10/14
to resour...@googlegroups.com


Pada Selasa, 24 Juli 2012 8:39:15 UTC+7, Electric Art menulis:
Hi there,

We have a ResourceSpace library that we have setup that uses StaticSync to create previews/thumbnails of resources.

Currently running Ubuntu 11.04 Server, using ImageMagick 6.6.0-4.

We are using ImageMagick as we need to support PSB files. We are having a problem though, in that ImageMagick chews up all the RAM allocated to the server within seconds of trying to generate a preview for a PSB file, and eventually, an hour or more later, results in a blank white preview (if at all). Even our smallest PSB files (just over 2GB) are a problem, and we have PSB files as big as 11GB! After looking into the ImageMagick forums/documentation, it seems it is possible to tell ImageMagick to extract the preview layer that Photoshop generates (Photoshop saves a flattened copy of the file in PSD and PSB files if you tell it to save with compatibility for previous versions) by telling it to extract layer [0] and work with that instead. Is there a way I can configure ResourceSpace/StaticSync so that, for PSB files only, so that it tries to extract the preview layer instead of trying to generate it's own composite of the PSB (which it seems to fail at and take forever to do).

So, for example, by adding [0] after the filename with the convert command, we can extract the Photoshop flattened version (which I assume will save time/processing power and hopefully give us something useful!);

convert boots.psd[0] -thumbnail 340x340 boots_png.png

How would I go about implementing this in ResourceSpace? I can't seem to find the code where I would try this? Should I be looking in the delegates file for ImageMagick? I couldn't seem to find PSB in there, but is that because PSD and PSB files are treated the same?

Any help on this matter would be greatly appreciated!

kind regards,
Tristan.

hai mr,
I want ask how the install the ffmpeg for video play other than flv? 
Reply all
Reply to author
Forward
0 new messages