ZenphotoCMS Forum
Creating thumb from image (preview of pdf, eps) - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: Creating thumb from image (preview of pdf, eps) (/thread-10828.html)

Pages: 1 2


Creating thumb from image (preview of pdf, eps) - mlodszy - 2013-02-07

Hi,
I'm writing an plugin that create an image from first page pdf, eps files to preview what is in document. After some review I used class-WEBdocs as base of new one.

I have:

  • upload
  • checked function of generating image(by ghostscrip)

In class-WEBdocs use static images, but I want to generate a thumb of image which will be stored in directory. Is there a class for it and can you indicate in which file is used?

Other thing - is there any place to disable scaning for images placed in directory, in albums? (/albums/sample_direcotry)




Creating thumb from image (preview of pdf, eps) - sbillard - 2013-02-07

Do you want to generate a thumb for each document or just a different default thumb? For the former, just place the generated thumb in the folder. The filename of the thumb should be the same as the document except that the suffix should be that of an image rather than pdf. If you want to have a different default thumb, create that image and place it in your plugins/class-WEBdocs folder. Name it pdfDefault.png.

There is a plugin that will disable scanning of folders and/or file suffixes. It is named filter-fileSearches and may be found in our repository of unsupported code on GitHub.




Creating thumb from image (preview of pdf, eps) - acrylian - 2013-02-07

http://www.zenphoto.org/news/why-does-zenphoto-not-show-a-thumbnail-from-my-video-




Creating thumb from image (preview of pdf, eps) - mlodszy - 2013-02-07

I want to generate thumb for each document. Like I'm write for each file I will generate full size preview image of first page document and stored it on the disc.




Creating thumb from image (preview of pdf, eps) - mlodszy - 2013-02-07

@acrylian thanks. If i think good i need only place image in the same direcotry that file and name it with the same name, with lower case?

Then I must in "function getThumbImageFile" indicate on this file?




Creating thumb from image (preview of pdf, eps) - acrylian - 2013-02-07

As the article tells the image must have the same name as the actual file except the suffix naturally. This way works with all supported formats via plugins like videos, text objects or the webdocs without needing to indicate anything.




Creating thumb from image (preview of pdf, eps) - mlodszy - 2013-02-07

Thank you for your time




Creating thumb from image (preview of pdf, eps) - mlodszy - 2013-02-08

After some work and testing I came with one problem - getting a full path to file.

$filename = $this->filename;
$album = $this->folder;
$ff_src_file = $_SERVER['DOCUMENT_ROOT'] . '/' . $albums . '/' . $filename;

But have an error with
NOTICE: Undefined property: EXTdocs::$folder in /zp-core/zp-extensions/class-EXTdocs.php on line 138 EXTdocs->getThumbImageFile called from TextObject->getThumb (class-textobject_core.php [162]) from getImageThumb (template-functions.php [2627]) from printImageThumb (template-functions.php [2645]) from include (album.php [56]) from index.php [100]
Have you mayby some good solution for get the right path?




Creating thumb from image (preview of pdf, eps) - acrylian - 2013-02-08

$filename = $this->filename; $album = $this->folder;
That cannot work, first $this is a variable within a class and then images and albums are different objects. EIther it is an album object or an image one. In any case filename and folderwon't work on both.
Please read: http://www.zenphoto.org/news/zenphotos-object-model-framework
and review the documentation of the main Zenphoto classes. If you haven't you should read the theming tutorial as well.

If you just want the full image url there are template functions available.




Creating thumb from image (preview of pdf, eps) - mlodszy - 2013-02-08

`
and review the documentation of the main Zenphoto classes. If you haven't you should read the theming tutorial as well.

If you just want the full image url there are template functions available.
You don't understand. I don't use this in theme but in class. I sed: full path to file. Not url - i need something like /home/some/some/albums/test`




Creating thumb from image (preview of pdf, eps) - acrylian - 2013-02-08

What class do you use this in? $this refers to the class object itself. In any case that NEVER can be an image object or an album object at the same time.

home/some/some/albums/test
What is "some" here?

You get the url to an item (which refers to any supported items) within an album via getFullImageURL() if in the right context. Otherwise you need to create an image object first to use the method. Before you can create an image object you need the object of its album. That is explained on the object model tutorial.

If this file is outside the albums and not supported by a plugin like videos you cannot use the object model naturally.




Creating thumb from image (preview of pdf, eps) - mlodszy - 2013-02-08

I use: class-textobject_core
I base plugin on: class-WEBdocs
I want to get:
SERVER_DOCUMENT_ROOT/BASE_ALBUM_DIR/ALBUMS/Filename

Like I write above, I want to create an image from uploaded file. For that I need to tell ghostscript from where get file and where storage image file.




Creating thumb from image (preview of pdf, eps) - acrylian - 2013-02-08

The textobject class is an extension of the image class and inherits its methods. So the url will be $this->getFullimageURL().




Creating thumb from image (preview of pdf, eps) - mlodszy - 2013-02-08

I sed above - i don't need FileURL(http://) - i need path (/home/path)




Creating thumb from image (preview of pdf, eps) - acrylian - 2013-02-08

http://www.zenphoto.org/documentation/classes/_Image.html#methodgetFullImage




Creating thumb from image (preview of pdf, eps) - mlodszy - 2013-02-08

Thanks! I got all worked up now

After some improves in code, I want to publish for other. Can you say how/where send/publish, so that others also have the chance to use?




Creating thumb from image (preview of pdf, eps) - acrylian - 2013-02-08

Please see: http://www.zenphoto.org/news/general-contributor-guidelines




Creating thumb from image (preview of pdf, eps) - mlodszy - 2013-05-23

I manage to create class (based on other one) that generate pdf/eps/tiff preview. It's have some code to improve/erase but working well.

If someone need, find here: http://pastebin.com/J7iJcWZG

Mayby one day I have time to finish it or mayby someone do it for me




Creating thumb from image (preview of pdf, eps) - acrylian - 2013-05-23

Is that a static link so we can add it to the extensions section?




Creating thumb from image (preview of pdf, eps) - mlodszy - 2013-05-23

Yes, it's static. There will be no change and have life time set to forever