Module: PDF Proof Sheet (a.k.a Contact Sheet or Index Sheet)
shadlaws
Joined: 2012-03-14
Posts: 183 |
![]() |
|||
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, Edit: 2012/03/30 for version 4 - removed discussion of needing separate FPDF install.
|
||||
shadlaws
Joined: 2012-03-14
Posts: 183 |
![]() |
|||
I made a slight update to deal with displaying super-long file names a bit more nicely. Revision in above attachment still. Thanks, |
||||
shadlaws
Joined: 2012-03-14
Posts: 183 |
![]() |
|||
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, |
||||
shadlaws
Joined: 2012-03-14
Posts: 183 |
![]() |
|||
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, |
||||
floridave
![]()
Joined: 2003-12-22
Posts: 27300 |
![]() |
|||
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! Dave |
||||
tempg
Joined: 2005-12-17
Posts: 1857 |
![]() |
|||
I haven't used it yet, but it sounds great! Thanks @shadlaws. |
||||
shadlaws
Joined: 2012-03-14
Posts: 183 |
![]() |
|||
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'm curious to hear how it works for you guys! |
||||
jnash
![]()
Joined: 2004-08-02
Posts: 814 |
![]() |
|||
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 |
![]() |
|||
@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, |
||||
jnash
![]()
Joined: 2004-08-02
Posts: 814 |
![]() |
|||
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
![]()
Joined: 2003-12-22
Posts: 27300 |
![]() |
|||
No buttons for me either. Yes, I did change the folder name to proofsheet removing the _4 Dave |
||||
jnash
![]()
Joined: 2004-08-02
Posts: 814 |
![]() |
|||
Oh, and yes, I did remove the _4 as well... no dice, either way. |
||||
shadlaws
Joined: 2012-03-14
Posts: 183 |
![]() |
|||
@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: 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, |
||||
jnash
![]()
Joined: 2004-08-02
Posts: 814 |
![]() |
|||
That seems to have done the trick. All is well for me! |
||||
shadlaws
Joined: 2012-03-14
Posts: 183 |
![]() |
|||
@jnash - excellent, glad to hear it! Thanks, |
||||
jnash
![]()
Joined: 2004-08-02
Posts: 814 |
![]() |
|||
Nice work by the way. |
||||
floridave
![]()
Joined: 2003-12-22
Posts: 27300 |
![]() |
|||
shadlaws, Thanks for your contribution and the DOCS look great as well.! Dave |
||||
shadlaws
Joined: 2012-03-14
Posts: 183 |
![]() |
|||
@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, |
||||
floridave
![]()
Joined: 2003-12-22
Posts: 27300 |
![]() |
|||
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. 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 |
||||
shadlaws
Joined: 2012-03-14
Posts: 183 |
![]() |
|||
@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 I'll change that in the near future Take care, |
||||
shadlaws
Joined: 2012-03-14
Posts: 183 |
![]() |
|||
Alright, it's done - version 5 is uploaded. - Added ability to include GIF thumbnails if GD is installed (FPDF uses GD) Thanks! |
||||
shadlaws
Joined: 2012-03-14
Posts: 183 |
![]() |
|||
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, |
||||
michaelnyden
Joined: 2012-04-16
Posts: 27 |
![]() |
|||
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 |
![]() |
|||
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, |
||||
michaelnyden
Joined: 2012-04-16
Posts: 27 |
![]() |
|||
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 |
![]() |
|||
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, |
||||
michaelnyden
Joined: 2012-04-16
Posts: 27 |
![]() |
|||
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 |
![]() |
|||
@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, |
||||
indigoxela
Joined: 2012-06-14
Posts: 1 |
![]() |
|||
Hi shadlaws, This error is caused by a nasty little typo in controllers/proofsheet.php in line 217: There's a single hyphen missing before ">installed" in version 5 (recent) of this plugin. Oh - and thank you for this useful little module. |
||||
shadlaws
Joined: 2012-03-14
Posts: 183 |
![]() |
|||
Hi indigoxela, Ack - you're exactly correct! I've fixed the module and uploaded version 6 above. Thanks for the catch! Take care, |
||||
shadlaws
Joined: 2012-03-14
Posts: 183 |
![]() |
|||
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, |
||||
mtm
Joined: 2010-10-19
Posts: 5 |
![]() |
|||
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 |
![]() |
|||
@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: Have fun! Take care, |
||||
shadlaws
Joined: 2012-03-14
Posts: 183 |
![]() |
|||
@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 |
![]() |
|||
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 |
![]() |
|||
@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, |
||||
mtm
Joined: 2010-10-19
Posts: 5 |
![]() |
|||
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 |
![]() |
|||
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 |
![]() |
|||
@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, |
||||
pinguinoj
Joined: 2012-11-20
Posts: 7 |
![]() |
|||
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 |
![]() |
|||
@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, |
||||
geoffh
Joined: 2013-04-01
Posts: 1 |
![]() |
|||
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
![]()
Joined: 2003-12-22
Posts: 27300 |
![]() |
|||
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 _____________________________________________ |
||||
shadlaws
Joined: 2012-03-14
Posts: 183 |
![]() |
|||
@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, |
||||