Creating thumb from image (preview of pdf, eps)

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)

Comments

  • 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.
  • 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.
  • @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?
  • acrylian Administrator, Developer
    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.
  • Thank you for your time :)
  • 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?
  • acrylian Administrator, Developer
    `
    $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 `folder`won'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.
  • `
    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`
  • acrylian Administrator, Developer
    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.
  • 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.
  • acrylian Administrator, Developer
    The textobject class is an extension of the image class and inherits its methods. So the url will be `$this->getFullimageURL()`.
  • I sed above - i don't need FileURL(http://) - i need path (/home/path)
  • 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?
  • mlodszy Member
    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 :)
  • acrylian Administrator, Developer
    Is that a static link so we can add it to the extensions section?
  • mlodszy Member
    Yes, it's static. There will be no change and have life time set to forever :)
Sign In or Register to comment.