New version of PictPress



I have prepared a new release of PictPress. A lot has been rewritten, what has stayed the same is the basic approach, automatic generation of posts from a directory of images. A major change is that I now focus on creating a post per image instead of appending one page per image to a single post. A master post contains thumbnails that point to the various picture posts. The old functionality is still there but will not be further developed by me.

Overview of what is new:

  • No need for .htaccess changes.
  • Independent of rdjpgcom and exif_read_data.
  • Resize either via ImageMagick or GD2.
  • All program files stored in the plugin directory.
  • Image files stored relative to the upload directory.
  • All settings are now stored in the database instead of a config file, and can be adjusted through an edit form.
  • A lot of the automatically generated strings can be configured.
  • EXIF information can be included in captions etc.
  • Template functions that generate a prev/next thumbnail for picture posts.
  • Protection against image bandwidth stealing.
  • Comment strings are left in the posts to see a bit of what PictPress has been doing (but this probably does not solve all of the debugging problems).
  • Improved error checking in resize script.

For more information see the full description.

Update (15 sep): I updated the zip file to fix some typos, missing mysql escapes and add the new readme.html. Download is still at http://www.curioso.org/pictpress-0.99.zip

38 Responses to “New version of PictPress”

  1. Troy says:

    Hi Curioso,

    You new plugin looks pretty polished! It was a lot easier to set up than the first one, especially w/o permalinks or the necessity of ImageMagick. I have a problem, though. The plugin appeared to install successfully, and I have it enabled. I have set up a directory with .jpg photos as such: “wp-content/images/2004/09/apartment-pictures”. My image directory is specified in the Pictpress options as “images/%year%/%monthnum%/%postname%”. Is this correctly set up?

    When I created the post with the slug title “apartment-pictures” nothing shows up. In all actuality, nothing appears any different than if I hadn’t installed PictPress.

    Can you point out where I might start debugging this one? I hate bugging benevolent developers for tech support.

  2. Curioso says:

    If PictPress does not find a directory or pictures it will leave a comment like <!–pp-thumb-start–><!–PictPress found no dir /home/curioso/public_html/images/2004/09/pictpress-099–><!–pp-thumb-end–> at the end of the post. Your post does not contain such a comment, so I assume PictPress stops somewhere on a fatal error. Because WordPress sends a Location header before finishing processing the post form, errors will not be shown. To show errors, you can remove the comment slashes at the end of the pictpress.php file (echo “PictPress loadedn”;). This will cause PHP to ignore the Location header and show any error messages that might be produced.

  3. Troy says:

    Thanks for the response, Curioso.

    After enabling headers, I was getting an error about my apostrophes and quotation marks. I put some backslashes in front of them (in the post), then I got a whole new host of errors on my next post.

    Turns out PictPress was also unhappy with the apostrophes in my .jpg filenames (I use Win2k3 for my server, so apostrophes are allowed in filenames).

    Fixing it (I believe) would be as easy as htmlentities() or something similar.

    I am currently working on debugging an issue with my image directory (which is due to a bug in WordPress, not your plugin). I am 90% sure that PictPress will work after I resolve it.

    Thanks for the great work. I am learning a lot from leafing through your code to get PictPress up and running :-)

  4. Curioso says:

    I assume some mysql escapes are missing.
    Can you try these changes in pictpress.php:

    234c234
    < $content = implode("<!--nextpage-->", $newpages);
    ---
    > $content = $wpdb->escape(implode("<!--nextpage-->", $newpages));
    332a333
    > $content = $wpdb->escape($content);
    374c375
    < $content = implode("<!--nextpage-->", $newpages);
    ---
    > $content = $wpdb->escape(implode("<!--nextpage-->", $newpages));

  5. Troy says:

    Yep, those changes did the trick. No more problems with apostrophes or quotation marks.

    I spotted (what I think is) an error in resize.php, line 87. $dst = magecreatetruecolor($w, $h); should be $dst = imagecreatetruecolor($w, $h);

    With that correction made, these are now the errors I’m getting. I don’t know enough about the GD library (yet) to debug all of them. They might be Windows-only bugs, but I do have the GD2 extension working.

    Warning: imagecreatetruecolor(): Invalid image dimensions in C:\Inetpub\Watercascades\troy\wordpress\wp-content\plugins\pictpress\resize.php on line 87

    Warning: imagecopyresampled(): supplied argument is not a valid Image resource in C:\Inetpub\Watercascades\troy\wordpress\wp-content\plugins\pictpress\resize.php on line 88

    Warning: imagejpeg(): supplied argument is not a valid Image resource in C:\Inetpub\Watercascades\troy\wordpress\wp-content\plugins\pictpress\resize.php on line 89

    Warning: imagedestroy(): supplied argument is not a valid Image resource in C:\Inetpub\Watercascades\troy\wordpress\wp-content\plugins\pictpress\resize.php on line 90

  6. Curioso says:

    Please try this change in resize.php:

    85,87c85,87
    < $w = floor($scale * $x);
    < $h = floor($scale * $y);
    < $dst = magecreatetruecolor($w, $h);
    ---
    > $w = floor($scale * $sx);
    > $h = floor($scale * $sy);
    > $dst = imagecreatetruecolor($w, $h);

  7. Dave Seah says:

    I’ve been having trouble getting this to work…I wasn’t seeing any files generated by resize.php. I was using FireFox on Windows XP.

    I then noticed it seemed to work fine on Safari and on IE6.

    It seems that the img src url generated by PictPress doesn’t work if you change it from the default (”%year%/%monthnum%/%postname%”) to what I had it as (”images/%year%/%monthnum%/%postname%”).

    Replacing “images/” with “images//” in the PictPress options allowed it to work correctly in FireFox.

    It looks like the output is still generating some extra symbols…I’m not sure if it is a PHP configuration thing with my particular host (pair.com) or a side effect of the additional escaping that was added to 0.99a. Thought I’d mention it though!

    Thanks for the plugin…it’s pretty sweet!

  8. Curioso says:

    Dave, I am not sure what is happening here.
    I tried changing the image dir myself, and that worked OK in Mozilla 1.8a2 under Windows 2000. I am using Firefox on Mac at home and have not seen any problems there either.

  9. Curioso says:

    I found the problem with single quotes in filenames not working, bit by the magic slashes that I already heard so much of :-(

    Put the following change in resize.php:

    18a19,20
    > if (get_magic_quotes_gpc())
    > $path = stripslashes($path);

  10. martin says:

    Hi Curioso.

    Got it kinda working. I can post, but the image resize is not working.
    I commented in the echo as you indicated in 2 and found that the error_log was showing the following statements

    convert: Unrecognized option (-resize).
    convert: Unrecognized option (-resize).
    convert: Unrecognized option (-resize).

    even thought i get the following code for the blog entry.

     
    barcelona
    barcelona
     


    I have tried it with, FireFox, Opera and Safari and it does not show for any browser.

  11. Curioso says:

    Martin, maybe you have a different program convert than the ImageMagick one…
    Try setting pp_resize_method to “GD2″.

  12. Trevor says:

    I was wondering if this is still going to work with 1.3

  13. Carina says:

    I’ve got a similiar problem like John - the resized images aren’t shown, but the originals work fine.

    I’m on safemode, too; and I’ve figured out that the script cannot write into the cache at all - if there a way to deactivate the cache, so that the thumbs are created on the fly?

  14. Carina says:

    Or it could be a totally different problem…
    if I look at the path of the thumbnails (with right-click - show image, in Firefox), it says …rezise.php?size=100&path=fanart%2Fimage.jpg

    The %2F should be a / shouldn’t it? What do I do against that?

  15. Joel Watts » Just call me Lenny. says:

    […] under: Meta — Joel @ 10:09 pm

    I killed it. I was trying to add the [PictPress] (http://www.curioso.org/2004/09/14/pictpress-099/ “PictPress”) plugin to my [WordPress] (http://wordpress.org/ “WordPress”)installation and […]

  16. Joel Watts » Just call me Lenny. says:

    […] under: Meta — Joel @ 10:13 pm

    I killed it. I was trying to add the [PictPress] (http://www.curioso.org/2004/09/14/pictpress-099/ “PictPress”) plugin to my [WordPress] (http://wordpress.org/ “WordPress”)installation and […]

  17. Joel Watts » Just call me Lenny. says:

    […] under: Meta — Joel @ 10:13 pm

    I killed it. I was trying to add the [PictPress] (http://www.curioso.org/2004/09/14/pictpress-099/ “PictPress”) plugin to my [WordPress] (http://wordpress.org/ “WordPress”)installation and […]

  18. Joel Watts says:

    I’m really sorry about the triple post. I actually didn’t mean to comment at all. I’m just starting to play around with WordPress and forgot about TrackBacks.

  19. Przemek says:

    Great plugin, thanks !
    But I saw big difference when vewing in :
    1) Opera 7.51 on WinXP, Mozilla (compiled) on Debian, Firefox 1.0 on WinXP
    2) Mozilla 1.7 on WinXP, IE

    ad 1)
    When plugin enabled, my story content is just after menu on the left side (so I got on the first page a lot of free space ;) )

    ad 2)
    looks good

    Somehow, when main css contains ‘float=…’ there is a little mess because pictpress css, I guess….

  20. MoebiuZ says:

    This is a great plugin, but it have some problems when using Textile 1 (I don’t know if with Textile 2 or Mrkdown too).
    The problem is that some comments (specially <!–pp-thumb-start–> and <!–PictPress generated page for image (.*?) –>)
    appears in the post, behind the image. That’s due to any kind of text reformating <!- and tries to put in this place another image (I think an icon or something). I was able to hide some commenting some parts of php code without affect the normal work of the pictpress, but there are one (when you hit a thumbnail to see the post of the individual image) that I can’t resolve.

  21. John says:

    It’s really nice if I can get it to work compeletely. If I have a few pics like 2 or 3, it works fine. But when I try to do 25 pictures, it doesn’t work. When I do this, I see it had created 3 photo pages in the “Edit” section. No thumbnail is created in the original post.

  22. Curioso says:

    Moebiuz, I have no experience with Textile. I have seen that autowp also has a bit of a problem with the comments I insert, but I need those partly for debugging and prtly to be able to update posts later, and I do not know another solution. Can Textile be modified to leave HTML comments alone?

    John, I have not seen any problems with inserting many pictures. My guess would be that there is a timeout interfering with the execution of the edit post form…

  23. Jeff says:

    Ack! I *thought* I had it running, but the pictures aren’t being put in their cache folders. The page is here: http://rpsigns.net/test/exterior/new.php (pardon the colored borders…having other difficulties as well!)

    The program created directories cache/100/ncross and cache/600/ncross all with permissions set to 755, but doesn’t seem to be able to write to them?

    I can’t delete or change permissions on the folders, either. Is the owner supposed to appear as ‘httpd’? Is this even my problem, or might it be something else? …looking forward to using the plugin, though! :-)

  24. David Hong says:

    Hi Curioso,

    The PictPress is working great on my site, except for one bit. The thumbnails are not being displayed properly. I tried fixing it my self using the previous post on PictPress where someone also had the same problem as me. Here are the details:

    WordPress director is /home/kioria/public_html/;
    PictPress folder and pictpress.php is located in ../public_html/wp-content/plugins/;
    The image folders (%year%/%monthnum%/%postname%/ is in ../public_html/wp-content/;
    The cache directory is created in:
    ../public_html/wp-content/; given chmod 755;

    The .htacess file is in: ../public_html/; and has been modified to include both your .htacess version and WordPress 1.5 permalink structure methods.

    *Sample problem* If you visit my website, you will see the newest post having 2 PictPress generated thumbnails, without any image being displayed. When clicked on, it works perfect. It seems like the thumbnail generation is the only problem at this time.

    Below are the configuration of PictPress:
    pp_cachedir: cache/%size%/%path%;
    pp_image_dir: %year%/%monthnum%/%postname%;
    … omitted.

    *** FIXED WHILST POSTING THIS ***
    the pp_cache_dir was given chmod 777. This enabled my thumbnails! GREAT WORK CURIOSO LOVE THE PICTPRESS!

  25. Petzlux says:

    Hi

    I just got Picpress on my blog running, but there is a problem when I have Textile or Markdown running in paralell. Picpress adds the thumbnails and everything works, but the comments it adds to the post like for example :

    can be seen in the post, and is not contained only in the html sourcecode.

    I suspect the way textile and markdown process the user input, they somehow convert the html comments.
    I worked around it by switching markdown or textile of, but would like to be able to use them again , also when making picpress posts.

    Can anyone help me ?

  26. Curioso says:

    Petzlux, what you might try is to insert the following at the end of pp_expand_subtitles (before the return statement):

    $content = preg_replace('/<!--.*?-->/', '', $content);

    This removes all comments from the content of a post when it is displayed on a page.
    Further check that the priority of pp_expand_subtitles is lower than the priority of the Textile/Markdown filters. This is currently set to 5 in these lines at the end of pictpress.php:

    add_filter("the_content", "pp_expand_subtitles", 5);
    add_filter("the_excerpt", "pp_expand_subtitles", 5);

  27. Petzlux says:

    I did some more investigation of the problem, and the thing is, as far as i can tell, pictpress relies on the comments that it inserts into the post to tell if a post has images associated with it , so removing these comments would break the working of the plugin.

    So it doesnt seem to matter if textile kicks in before or after pictpres (in terms of plugin priority).

  28. Curioso says:

    Petzlux, you are right that PictPress needs most of the comments it puts in the posts for its own operation, but the filters I was referring to work only when displaying a post, and leave the comments in the database. As fas as I know, textile and markdown also only filter when displaying, so when you filter out the comments before the textile/markdown filters, these filters should work OK. It would fail if textile/markdown write back the filtered content to the database…

  29. Petzlux says:

    Im back and its working now, I really like the pictpress script because of the way how it integrates into wordpress. the pictures feel like part of the fabric of the site and the individual posts, and not like a separate entity as with most gallery scripts.

    BUT, I still have one issue. I know its probably annoying, but Curioso, would it be possible for the script to generate square thumbnails ?? They would just look better in the layout and would be easier to neatly write CSS for. I dont know if it would be much work, I found a php function that generates square thumbnails, but, as it seems pictpress uses one function to output thumbs and the resized images. I dont know how to discernate then between the case when pictpress requests a thumbnail or a resized pic.

    Curioso, have you encountered that , and would you be willing to tell me if this would be feasible to have square thumbnails ?

  30. Curioso says:

    Petzlux, can you provide me with the PHP function that you are referring to to generate square thumbnails?
    I assume this would scale the smallest dimension to a preset size and crop the largest dimension to the same size.
    I have some ideas on how to integrate this with the rest, i.e. the cache directory and my resize.php script. I would also have to add yet another option :-(

  31. Petzlux says:

    http://uk2.php.net/manual/en/function.imagecopyresampled.php

    this is the closest that I could find, they have some code snippets to create thumbs specifying and keeping height and width.

    Thanks for being so helpful !

  32. Curioso says:

    Petzlux, you can try it in the new version at http://www.curioso.org/download/pictpress.zip
    You get square thumbnails if you fill in e.g. 100×100 in the pp_thumb_size option.
    I could not test the GD2 functions because I do not have that on my system.
    The ImageMagick part seems to work (see http://www.curioso.org/2004/08/29/treble/).

  33. Petzlux says:

    Worked like a charm even with GD !! Thanks so much for the help and building in my request. You can see it in action at my website!

  34. John Minnihan says:

    Hey Curioso,

    This plugin looks great, but I am having trouble getting the thumbnails produced. So far, I can create a new post, supplying the pre-made directory full of images (and the matching postslug). PictPress generates the post, creates the cache dir but doesn’t create the thumbnails (or at least doesn’t place them anywhere I can see)

    I have allowed for echoing of $image and $cache per your suggestions in above comments, and it looks like the cache directory is null - see below message from my browser when I click on what should be the full-image link:

    PictPress loaded image: ‘/usr/local/apache2/htdocs/wordpress/wp-content/2005/06/hawaii/john-and-boys-hawaii.jpg’, cache: ‘’

    While this is probably a smoking gun, where can I look to ensure that it isn’t simply a symptom of another issue? I have set cache dir in the options, but have also noticed there is no “Save” or “Update Options” button on the pictpress options page… maybe the options aren’t really set?

    I am using:

    - Fedora core 3
    - PHP 4.3.11 ‘./configure’ ‘–with-apxs2=/usr/local/apache2/bin/apxs’ ‘–with-mysql=/usr/local/mysql’ ‘–with-gd’ ‘–with-zlib’ ‘–with-jpeg’
    - Wordpress 1.5
    - Pictpress 1.0alpha plugin from subversion
    - Firefox 1.0.4 (Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Fedora/1.0.4-1.3.1 Firefox/1.0.4)

    The server is under my full control, so I can make any edits suggested.

    Thanks in advance,

    John Minnihan
    Founder, https://freepository.com

  35. Frando says:

    Hello!

    First of all, I like your plugin very much, it’s the best photogallery plugin i’ve found till now!

    I’m using wordpress 1.5, and it seems to be running well!

    just two points:

    1) is it possible to make the picture post not appear on the front page? because if I create a photogallery with 20 entries, there’s nothing on the home page than all these photos…

    2) where can I set the category to which the photos belong?
    They have always just the same category than the gallery post they belong to, but it would be rather useful to have them all together in a “PictPress”-gallery or something like this…
    I’ve looked through pictpress.php, but I didn’t find the call which sets the category belongings..

    best regards,
    Frando

  36. Curioso says:

    Frando,

    1) I have to look into this. For WP 1.5 the intention was to omit the picture posts from the loop in a number of cases, but apparantly I missed the front page.

    2) You can try to set the pp_image_cat option, but I am not using this myself, so I am not sure it if works and if it does what you intend.

  37. Warjo says:

    I am running WP 1.5 and your plugin is working great. Although everytime i post i get this error “Warning: main(ABSPATH/wp-admin/auth.php): failed to open stream: No such file or directory” although the post still posts fine and everything seems to work ok. I have checked the directory and made sure the file was there. Any ideas?

  38. Curioso says:

    The problem with posting should now be fixed.