Module: PDF Proof Sheet (a.k.a Contact Sheet or Index Sheet)

shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Tue, 2012-03-27 18:14

Hey everyone,

NEW: Version 7 is out! (2012/10/05) - bug fix related to tags

I made a new module called proofsheet, which generates a PDF proof sheet (a.k.a. contact sheet). It adds two links, one for A4 and one for LTR, that generate an on-the-fly PDF of the current album or tag from thumbnails. The PDF has the album/tag title, page numbers, and image titles that are hyperlinked to the actual gallery pages.

I based the code on downloadalbum (by rledisez). It does *not* require ghostscript, so it is fine with GoDaddy. Rather, it uses FPDF, which is a php class that builds PDFs. It's available at http://www.fpdf.org/, and included as a library.

Installation instructions are as typical with a module download and unzip proofsheet to the modules directory then enable it.

Documentation is available at http://codex.gallery2.org/Gallery3:Modules:proofsheet. I tried to structure the code so it's relatively easy to understand and modify, and I included in this documentation is a discussion of how to tweak the various parameters to your liking.

Let me know what you guys think!

Thanks,
Shad

Edit: 2012/03/30 for version 4 - removed discussion of needing separate FPDF install.

AttachmentSize
proofsheet_7.zip228.91 KB
 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Tue, 2012-03-27 19:56

I made a slight update to deal with displaying super-long file names a bit more nicely. Revision in above attachment still.

Thanks,
Shad

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Tue, 2012-03-27 21:24

I discovered a bug... actually, a bug in another module that caused incompatibility. When used, the missing_movie.png file was getting transferred into a thumbnail with the extension .jpg. Then, when this code found a jpg file that wasn't actually a jpg, it'd crash.

So, I fixed it - v1.2 now determines if it's a jpg or png itself, regardless of the file extension. Problem averted :-)

Take care,
Shad

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Wed, 2012-03-28 09:46

I made a few more changes, which should make it much easier for other folks to read and tweak as they like. Then, I changed the version numbering (didn't realize Gallery only wants whole numbers), added the documentation wiki, etc.

If y'all have any feedback, let me know. Thanks!

Take care,
Shad

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2012-03-28 15:12

I have not looked closely at the code or the license for the fpdf17 file but could you not include it in a library and call it like:

      include MODPATH .'proofsheet/lib/fpdf17.php';

Saving editing the file.

Thanks for your contribution and the DOCS as well!
Will test it out some time, when I get a chance.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Thu, 2012-03-29 11:17

I haven't used it yet, but it sounds great! Thanks @shadlaws.

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Fri, 2012-03-30 10:26

I released a new version - version 4. @floridave - good suggestion. I read through the license of FPDF and it's completely free to modify or distribute as you like. So, it's now a library :-). I also fixed some encoding issues with diacritics, make the header link into an icon, and did a major rewrite of the code structure to make it slicker and simpler to modify for other folks' purposes. Docs are updated as well with examples on how to tweak things.

I'm curious to hear how it works for you guys!

 
jnash
jnash's picture

Joined: 2004-08-02
Posts: 814
Posted: Fri, 2012-03-30 13:37

Doesn't seem to work in the clean canvas theme at least... nothing shows up in the menus anywhere for a proofsheet... Unless I'm blind?

No errors in any of the logs.

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Fri, 2012-03-30 14:29

@jnash - it should appear not as a menu item, per se, but as an extra icon in the menu bar. A screenshot is below. Does yours appear in a similar place? If not, are there at least links there with alt-text but no image?

[img]http://www.shadlaws.com/webprojects/proofsheet_screenshot.png[/img]

Take care,
Shad

 
jnash
jnash's picture

Joined: 2004-08-02
Posts: 814
Posted: Fri, 2012-03-30 17:24

Nope, nothing showing, no icons, no links w/ or w/o alt text.

Nothing in the source either

EDIT: Changed to default WIND theme, and nothing showing there either...

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2012-03-30 19:40

No buttons for me either. Yes, I did change the folder name to proofsheet removing the _4
The css is not loading for me. That is my first observation. I don't know why yet but will dig this weekend.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
jnash
jnash's picture

Joined: 2004-08-02
Posts: 814
Posted: Fri, 2012-03-30 19:44

Oh, and yes, I did remove the _4 as well... no dice, either way.

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Fri, 2012-03-30 22:43

@floridave & @jnash - thanks for your help testing! And sorry for the trouble!

Alright, first off, I changed the directory name in the zip file. Of course it should be "proofsheet" and not "proofsheet_4." That was a dumb mistake - I fixed it in the zip file attached above. And to summarize the rest of this post, I suspect that could be the root of the problem.

At first, I tried to see if I could reproduce the problem, following the exact steps y'all would have done:
- uninstalled and deleted the module
- downloaded the zip, renamed the directory
- reuploaded the module and activated it
... and it still worked. I tried with greydragon and wind themes and it was great.

Then I realized there was one thing I did differently: the directory. I tried it again with the misnamed directory, activated it, and unsurprisingly it didn't work. Then I changed the name and it still didn't work. But, if I started over and renamed the directory *before* activating it, it worked great.

So, can you guys try deactivating it, then start over with the directory properly named beforehand?

As for the css file, it's super-simple and 2 lines long... I fail to see what could be screwy with it:

#g-view-menu #g-proofsheet-a4-link { background-image: url('../images/ico-view-proofsheet-a4.png'); }
#g-view-menu #g-proofsheet-ltr-link { background-image: url('../images/ico-view-proofsheet-ltr.png'); }

And here's the entirety of the theme file that references it:

class proofsheet_theme {
  static function head($theme) {
    return $theme->css("proofsheet_menu.css");
  }
}

Thoughts?

Thanks!

Take care,
Shad

 
jnash
jnash's picture

Joined: 2004-08-02
Posts: 814
Posted: Sat, 2012-03-31 02:21

That seems to have done the trick. All is well for me!

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Sat, 2012-03-31 06:25

@jnash - excellent, glad to hear it!

Thanks,
Shad

 
jnash
jnash's picture

Joined: 2004-08-02
Posts: 814
Posted: Sat, 2012-03-31 16:49

Nice work by the way.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2012-04-03 23:33

shadlaws,
Great job! It works for me. .gif images are an issue that needs to be addressed though.

Thanks for your contribution and the DOCS look great as well.!

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Wed, 2012-04-04 09:10

@floridave - thanks for the feedback!

The GIF exclusion was kinda-sorta by design on my end. As-is, the FPDF library doesn't do GIF natively, but does convert GIFs to PNGs if GD is installed. I could have written the code to check if GD is installed or generate functions that'd use another graphics package if it were installed. But since the module uses the *thumbnails* (not the full-size images) to generate the PDF, and I thought most folks had thumbnails that were only JPG or PNG, I didn't think it'd be worth the trouble. Is that in fact false and many people *do* use GIF thumbnails?

Take care,
Shad

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2012-04-04 13:46

I think in most cases GD would be installed. It is a default install for PHP. I have IM as a toolkit and GD is installed.
If getting .gif to work is a pain, then I think a better user experience is to either have a broken thumb on the pdf or skip them entirely.
I don't know the % of people that add .gif images to gallery so can only speculate. Perhaps my test case is an exception using a small .gif that is not converted to jpg for the thumb?

The current behavior(just bombing with a Kohana exception) in my test case, is not very good.

Otherwise I think this is a great addition.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Wed, 2012-04-04 16:30

@floridave - good point... at a minimum, the default behavior of throwing a Kohana exception may not be the most appropriate. I don't think it would be too hard to change it to:

- check if GD is installed and, if so, pass GIF images to FPDF
- simply skip the file instead of throwing a Kohana exception

I'll change that in the near future :-)

Take care,
Shad

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Thu, 2012-04-05 13:40

Alright, it's done - version 5 is uploaded.

- Added ability to include GIF thumbnails if GD is installed (FPDF uses GD)
- Changed behavior of unhandled file types - now provides missing image icon instead of throwing an exception

Thanks!
Shad

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Thu, 2012-05-03 11:50

Hey everyone,

Just a quick update - I've tested the module with v3.0.3 and it works without a hitch. No upgrade needed.

Thanks,
Shad

 
michaelnyden

Joined: 2012-04-16
Posts: 27
Posted: Fri, 2012-06-01 20:11

I have the latest version 5 on a windows iis server, in the past this module worked perfectly, now it generates the pdf, and prompts the web browser of the client to download the pdf, but never downloads it, or the download never starts. It shows a filesize, but it just pauses and never downloads.

Please help?

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Fri, 2012-06-01 21:50

Hmm... that's odd. It seems like it's getting hung up somewhere during file output. How big is the pdf file it's created and trying to send?

If you take a look in controllers/proofsheet.php, you should be able to find:

    /**
     * Output the PDF file.  I wrote it in two versions (one should always be commented out).
     */
    // Using a method similar to downloadalbum
    $pdfstring = $pdf->Output('','S');
    $this->prepareOutput();
    $this->sendHeaders($pdfname, strlen($pdfstring));
    echo $pdfstring;

    // Using FPDF directly
    //$pdf->Output($pdfname,'I');

One suggestion is to try and swapping output methods. Comment out the four lines under "Using a method similar to..." and uncomment the line under "Using FPDF directly." This is not as elegant of a way to do things, and bypasses Gallery's built-in systems, but it might be a nice place to start debugging.

If that passes, the next suggestion is to make a dummy file to send. Using the first method again, add a line after the first one that's painfully simple, such as:

    $pdfstring = $pdf->Output('','S');
    $pdfstring = 'Hello World';
    $this->prepareOutput();
    $this->sendHeaders($pdfname, strlen($pdfstring));
    echo $pdfstring;

This should spit out a file with the normal pdf name, but in fact is a Hello World text file.

Let me know what you find. Thanks!

Take care,
Shad

 
michaelnyden

Joined: 2012-04-16
Posts: 27
Posted: Mon, 2012-06-04 19:15

Okay, so I did the suggested tests.

Using the $pdf->Output method worked and put out the correct pdf, then I did the second test with $pdfstring = 'Hello World'; and it would spit out a 0KB pdf file that was unable to open/un-readable. Then I went back to the original method as well and it just starts the download on the browser, you can see the correct pdf name of the album, the size of the pdf is reported to the browser correctly, but it never downloads it just stays at 0% and 0KB of 225KB...so my pdfs are not that large or anything...

Any ideas?

For now, I left it to run the FPDF directly method which seems to work.

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Wed, 2012-06-06 21:19

Hmm, that's truly odd. By any chance do you use the downloadalbum module also? Does it still work? I ask because the output piece of the code I essentially copied from there...

Thanks for helping debug! And I'm glad at least we found a solution that works for your case.

Take care,
Shad

 
michaelnyden

Joined: 2012-04-16
Posts: 27
Posted: Wed, 2012-06-06 23:43

If you are talking about the download album as as zip module, then yes, I have it and it works, just tried it.

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Fri, 2012-06-08 18:02

@michaelnyden - hmm... that's confusing :-/ When I get some more time I'll take a look at why downloadalbum works and proofsheet doesn't, even if one copied its output code from the other. Weird.

Until then, I'm glad we found a workaround - nobody has to sit around with a non-functional Gallery :-)

Take care,
Shad

 
indigoxela

Joined: 2012-06-14
Posts: 1
Posted: Thu, 2012-06-14 10:11

Hi shadlaws,
I'm not sure if this is the right place for a bug report for proofsheet:
error: ErrorException [ 0 ]: Use of undefined constant installed - assumed 'installed'

This error is caused by a nasty little typo in controllers/proofsheet.php in line 217:
$cfgImageMissing['GDflag'] = graphics::detect_toolkits()->gd>installed;

There's a single hyphen missing before ">installed" in version 5 (recent) of this plugin.
Please fix it, as the error is fatal.

Oh - and thank you for this useful little module.

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Wed, 2012-06-20 14:52

Hi indigoxela,

Ack - you're exactly correct! I've fixed the module and uploaded version 6 above. Thanks for the catch!

Take care,
Shad

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Fri, 2012-10-05 11:14

Hey guys,

Found and corrected another bug related to proofsheets from tags (as opposed to albums). New version 7 is attached above. Thanks!

Take care,
Shad

 
mtm

Joined: 2010-10-19
Posts: 5
Posted: Sat, 2012-10-06 02:48

First off, thank you! Second, is it possible to modify proofsheet to include descriptions in the caption below filename?

Editing controllers/proofsheet.php, I tried duplicating line 250 ('name') and changing name to description, but to no avail. Any pointers? Am I even close? This would be great for users in need of a photolog/trip report. In fact, changing thumbnail to a small resize with 3 or 4 to a page vertically (with text adjacent to image) would positively hit the mark for such a need. This looks so close to that, but I'm such a novice it's hard to know for sure.

Many thanks again.

-Matt

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Sat, 2012-10-06 06:33

@mtm - yes, it's certainly possible to tweak the module as you need for your personal setup! And you have the right idea, namely that you need to edit that php file.

Here are the things you'll need to hack:
- Pull the descriptions in from each item. This is on lines 291 and 312.
- Change the sizes of things around, and make a new thing that goes between caption and image. You'll also need to define a new font setup (descFont, for example). These parameters are all setup in lines 105-222.
- Add another line below line 250 (that looks similar to line 250) that uses the description you pulled in lines 291/312, the font you defined above, and the new desc sizes.

Have fun!

Take care,
Shad

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Sat, 2012-10-06 06:35

@mtm - just realized one more thing, namely that I designed the printText function to add ellipses to things that are too long instead of doing a word wrap. May need to modify that as well... let me know if your serious about tweaking all the rest and I can see about adding a wordwrapping feature to that function.

 
Sirs1984

Joined: 2012-10-06
Posts: 1
Posted: Sat, 2012-10-06 07:26

im looking for the same thing and thank you for the advice i need it to improve my gallery

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Mon, 2012-10-08 16:40

@Sirs1984 and @mtm - I'm unfortunately a bit busy right now, so I don't have the time to help out with your requests. However, if you can wait 1-2 months, that could be a different story :-).

Take care,
Shad

 
mtm

Joined: 2010-10-19
Posts: 5
Posted: Wed, 2012-10-10 02:24

Just wanted to say thanks again! You've already been enormously helpful. Hopefully we'll turn out to be quick learners.

EDIT: See attachment for what an hour and a constant referring back to your advice can do. (Kids asleep, fire going and a glass of port may have helped.) All that is left is to figure out how to handle the ellipsis, then possibly reformat to left column with image, right column with name/url and description. If I get anywhere near that far, I'll consider a map for geotagged images (nearly all in ours are, as I send a gps with every camera and post-process with gpicsync).

EDIT 2: If anyone else following this has a pointer toward changing the thumbnail matrix layout to a 3-or-4-vertical images (smallest resizes?) with Title/URL and Description in a right-hand column, with word-wrapping, it would be tremendously appreciated. Ideally the Description would take priority over the number of images on a page, as for a "trip report" or "photo log" this could be a deliverable or even "evidence" depending on one's particular circumstances. I'll certainly keep looking but very much welcome any pointers or code examples.

--Matt

 
krzyzphoto

Joined: 2010-11-19
Posts: 11
Posted: Tue, 2012-11-06 20:49

I love your module. It would be even better if it worked along with the favourites module. I have users pick their favourites using the module. However when I go to their favourites link the proofsheet icons don't show up. Any chance there's a fix for this issue?

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Wed, 2012-11-07 16:59

@krzyzphoto - I'm glad the module is working well for you! I haven't personally worked with the favourites module, but taking a quick glance at the code, it seems the base reason for this is because the page_subtype of the view is "favourites" (see line 64 of controllers/favourites.php). Therefore, the menus (album_menu, photo_menu, tag_menu, ...) don't appear.

I don't have any plans to incorporate the favourites functionality in the near term... is there much interest in this?

Take care,
Shad

 
pinguinoj

Joined: 2012-11-20
Posts: 7
Posted: Thu, 2012-11-22 00:49
Quote:
Automatically detects if the current visitor has sufficient privileges to download the originals photos of the album and hides itself if that is not the case

please, i set e test user, he can download pdf. how i change the permission? should i create a new user group?thanks

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Tue, 2012-12-04 15:21

@pinguinoj - Hmm... I'm not sure I know what you mean. The PDF will only include images for which the user has view_full access. This is what you'll need to alter for a user group to change its behavior.

Thanks,
Shad

 
geoffh

Joined: 2013-04-01
Posts: 1
Posted: Thu, 2013-06-20 14:15
Quote:
Automatically detects if the current visitor has sufficient privileges to download the originals photos of the album and hides itself if that is not the case

I have just installed this module but all users, even those with no permission to view full size images, can see the icons. If users without permission to view full size image click on the icon they get the usual "Dang... something went wrong!" error

Is there any way to hide the icons for those users who don't have view full size permission?

Thanks.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Thu, 2013-06-20 14:35
static function album_menu($menu, $theme) {
      if (access::can("view_full", $theme->item)) {
$proofsheetA4Link = url::site("proofsheet/makepdf/a4/album/{$theme->item->id}");
    $menu
      ->append(Menu::factory("link")
          ->id("proofsheetA4")
          ->label(t("A4 Proof Sheet"))
          ->url($proofsheetA4Link)
          ->css_id("g-proofsheet-a4-link"));
    $proofsheetLTRLink = url::site("proofsheet/makepdf/ltr/album/{$theme->item->id}");
    $menu
      ->append(Menu::factory("link")
          ->id("proofsheetLTR")
          ->label(t("LTR Proof Sheet"))
          ->url($proofsheetLTRLink)
          ->css_id("g-proofsheet-ltr-link"))
      }
}

Add the red.....Not tested but should work.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Wed, 2013-06-26 07:56

@geoffh - ah, I see what you mean - it's not a security hole (i.e. they don't get access to something that should be blocked), but it's misleading/annoying that the icons are still there.

@floridave - thanks for the suggested patch! I've updated the zip file (and the git repo) to match :-)

Thanks,
Shad