Or, what happens when Jaipho meets PHP.
Although Jaipho is meant to be used as secondary image gallery script, some of my colleagues convinced me that there should be server side solution too. They just wanted to upload photos on server and let the script do everything else.
Pipho is exactly that. It reads photos from desired folder, on the fly creates resized thumbnail and slide images, and dumps Jaipho javascript read images part. In addition, it supports text files as descriptions for both, gallery and slides.
In short, Pipho is a PHP Jaipho implementation example.
If you are making iPhone optimized site, and you already do not have gallery engine on your site, this is perfect solution for you.
It is PHP5 package written in Zend Framework coding standard, but at this moment it does not requires any class from it. PHP classes are stored in library folder. Two classes are representing the main logic.
Pipho_DeviceInfo holds information about optimal images size for device which accesses the gallery. Right now it holds only iPhone information, but in a close future, Jaipho is planned to support other smartphones too (basic Android tests are already done and it looks find). You will also use it to check will user be redirected to Jaipho at all.
Pipho_FileManager is a class which have methods for loading photos from your desired folder. It will automatically create best fit thumbnails and slide images from your original photo. Results are returned as Pipho_Image and Pipho_Gallery objects. Pipho_Image class has method getJsReadImage() which will return image data formated as Jaipho Javascript dao.ReadImage() method.
Unpack download package and upload it to your webserver. Package also contains Jaipho javascript source, what means that it can be used without any additional download.
Ensure that the photos folder (PIPHO_PHOTOS_FOLDER constant) and all it's sub folders are writable. If this is not a case, Pipho will throw an exception. You can do it by running Linux command "chmod -R 777 photos/" from your webroot.
You can test it with browser on your desktop computer.
Please note that although Pipho_FileManager class has methods for listing all galleries, in the current Pipho version, there is nowhere you can actually see the list. Only way to switch galleries is to add an url argument e.g. ?gallery_id=mygallery
Example which has implemented gallery listings can be found in integration with iUI article at http://www.jaipho.com/content/using-jaipho-iui
1. Upload your photos inside the photos folder PIPHO_PHOTOS_FOLDER. Your photos have to be organized in folders: e.g. photos/mygallery/, photos/vacation/, photos/newimages/... Gallery folder name is used as gallery_id value. Photos folder should be inside your webroot folder. In other words, the photos should be accessible with your web browser. E.g. www.mysite.com/photos/mygallery/image.jpg
2. Add description file in each folder. It should be always named _gallery.txt. First line is a title, and all other lines are considered as gallery description. Gallery description is not used at the moment. This is optional step. If you skip it, gallery name will be set as it folder name.
3. You can add titles and description for your images. Just add txt filename with the same name as image has (for myimage.jpg, add myimage.txt). First line is image title, and all other is description (same as gallery description file).
In the moment when you try to see gallery with your browser, Pipho will check do the thumbnails and slides exists, and if they don't it will resize them on the fly.
It can be time consuming operation and there are two errors that PHP might throw.
- Fatal error: Maximum execution time of 30 seconds exceeded. You can increase execution time with PHP function set_time_limit ( int $seconds ).
- Fatal error: Allowed memory size of 33554432 bytes exhausted. This might happened if your photos are few MByets large. You can increase allowed memory for script with ini_set("memory_limit","64M")
Both of this functions should be added at the beginning of script where Pipho is implemented (index.php in downloaded package). It's recommended that you try all your galleries by yourself first, and after all thumbs and slides are created, you can remove those two functions.
At the beginning of index.php is set of constants which you can change to accomplish your particular needs.
PIPHO_PHOTOS_FOLDER - holds a path to your photos folder
PIPHO_FORCE_WRITE - if set to true, the image resizing will be called on every page load, no matter if the resized images already exists. Use it only for debugging.
PIPHO_SLIDE_RESIZE_ENABLED - if you already have optimal resized images for usage on iPhone, you can turn off resizing engine by setting this const to false. Otherwise, if enabled, your images can be downgraded in quality.
PIPHO_SORT_IMAGES_ENABLED - turn on or off sort order in which the images will be shown.
PIPHO_SORT_IMAGES_SORT_TYPE - as there are different types of sorting here you can set which particular type you need. For possible values you can check at http://www.php.net/manual/en/array.constants.php
PIPHO_SORT_IMAGES_REVERSE - set it to true if for any reason you need the reverse order
PIPHO_SORT_GALLERIES_ENABLED - same as the IMAGES version, with only difference that it affects the order in galleries list.
PIPHO_SORT_GALLERIES_SORT_TYPE - same as the IMAGES version
PIPHO_SORT_GALLERIES_REVERSE - same as the IMAGES version
Please note few more things
- PHP GD library has to be installed on your server. If it is not, you'll PHP will throw error "Call to undefined function imagecreatefromjpeg()"
- Pipho requires PHP 5. Otherwise, php will throw error with text "syntax error, unexpected '{'"
Comments
RE: Same image twice in test gallery
February 25, 2010 by Jesse (not verified), 1 week 6 days ago
Comment id: 120
I had the same problem as the person that posted the subject 'Same image twice in test gallery'.
If I had 5 images in the photos directory, all it showed was five of the same image.
I checked my PHP version and I was running 5.1.6. It was a big chore to update the PHP because my VPS had Plesk installed and apparently 5.1.6 is the latest version it supports.
I had my hosting company reprovision me a new VPS with Cpanel, which allowed me to update the PHP to 5.3.1.
After migrating my website to the new VPS with the current PHP, the duplicate images no longer existed and now this works perfectly.
Because I saw no end solution to the previous post about this problem, I thought I would pass on how I was able to resolve the issue.
Thank you for an awesome tool!!!
Portrait Images 480px Height
February 2, 2010 by Jon (not verified), 5 weeks 22 hours ago
Comment id: 107
Hey Tole,
I changed the css to optimize pipho in fullscreen app mode with translucent status bar (true fullscreen images ) , problem is some of the images (not all) are not resizing to 480height. Is there a property I can change to adjust this?
Also, I've been attempting to allow users to change the slideshow speed. I tried passing some variable to the Jph object but have had no luck, any ideas?
Thanks
RE: Portrait Images 480px Height
February 3, 2010 by Tole, 4 weeks 6 days ago
Comment id: 108
Hi Jon,
First the easy one. Slideshow speed is configured with SLIDESHOW_ROLL_TIMEOUT javascript variable (Jaipho part). For details and other configurable items check the http://www.jaipho.com/content/jaipho-configuration
The image size issue is not clear that much. The max size (both, width or height) is set in Pipho_DeviceInfo php class (Pipho part). As you can see it is allready set to 480px. So there should be no problem. I tried to reproduce that behavior with my photos, but all seems to be right.
Please contact me by contact form, and than you can mail me the problematic images.
Tole
Amazing script man! Only a
January 27, 2010 by marco (not verified), 5 weeks 6 days ago
Comment id: 104
Amazing script man!
Only a question... I'd like to load in the first time the gallery and then (only after clicking gallery thumbs) the photos.
How can I do that??
tnx a lot!
Open Jaipho in thumbs mode
January 28, 2010 by Tole, 5 weeks 5 days ago
Comment id: 105
Marco, check the "Startup modes" section on http://www.jaipho.com/content/installation-guide
I guess this is what you are looking for.
great!! tnx
January 29, 2010 by marco (not verified), 5 weeks 5 days ago
Comment id: 106
great!! tnx
Thumbnail image size
January 20, 2010 by Jon (not verified), 7 weeks 11 hours ago
Comment id: 95
Great script!
I need to get thumbnails around 120 px height and 75 px width,
any thoughts on how this could be accomplished?
Thanks
RE: Thumbnail image size
January 20, 2010 by Tole, 6 weeks 6 days ago
Comment id: 97
There are 2 places where you'll have to adjust thumbs size: in css (Jaipho) where the thumbs placeholder is defined, and in php side where thumbs are created (Pipho).
1. in jaipho.css there is a selector
.thumbnail. Change the width and height properties to your desired values. You'll probably want to adjust the margin property too, to adjust spacing between the thumbs.2. in php page which displays the gallery, after the line
$device_info = Pipho_DeviceInfo::getDeviceInfo();add this one
$device_info->thumbsSize = 120;Change 120 with whatever value you need.
This should fix it.
RE: Thumbnail image size
January 21, 2010 by Jon (not verified), 6 weeks 6 days ago
Comment id: 98
worked like a charm, thank you
Fullscreen Photo Description -
December 23, 2009 by robcox (not verified), 11 weeks 2 hours ago
Comment id: 82
Hey there, this is an awsome app. Thank you. I added paypal buttons to the description .txt which works pretty well. The only problem is half the time I tap paypal button, the description .txt is hidden. Where can I find the code to disable the hide description text function.
robcox
http://themidnightsun.net/mobileshop/albums.php
Persistent description
December 23, 2009 by Tole, 10 weeks 6 days ago
Comment id: 84
It should be easy one. Check the
JphSlider_Behaviorclass, andDescriptionTouchedmethod in it.Just remove
this.mrSlider.mrCompnents.Roll();line.Thank you for quick response
December 23, 2009 by robcox (not verified), 10 weeks 6 days ago
Comment id: 85
I figured it out right after posting for help. You're suggestion would have been easier. I set the description to stay on and hide the toolbars when text is touched. This app is awesome and I have received so many compliments from using your gallery template.
Thanks again,
robcox
Fatal Error
November 6, 2009 by Justin (not verified), 17 weeks 4 days ago
Comment id: 68
First off thank you for this wonderful tool. I successfully created a new gallery entitled GalleryPics and added images and descriptions. However, now when I try to add more images to the gallery I get this error:
Fatal error: Call to undefined function imagecreatefromjpeg() in D:\Inetpub\AutoSites\MobileSiteTest\Final\gallery\library\Pipho\ImageResizer.php on line 32
I am getting the same error when I try try to create another gallery called GalleryPicsLarge and add different images. What am I doing wrong?
GD library is not installed
November 7, 2009 by Tole, 17 weeks 3 days ago
Comment id: 69
Check on http://www.php.net/manual/en/image.setup.php how to install it.
thanks - image gallery sequence
October 17, 2009 by JaRo (not verified), 20 weeks 4 days ago
Comment id: 64
HI,
Thanks soooo much for this. Works like a charm, except for the sequence of images.
I have my files sequentially ordered such as Slide-1.jpg, Slide-2.jpg etc. However,
it doesn't present in that order. How can I fix that?
Sort order configuration
October 17, 2009 by Tole, 20 weeks 4 days ago
Comment id: 65
Since version 1.01, there is a set of configuration options for enabling sort of both images and galleries. By default, those values are set to enable alphabetic sort, so there should be no problem with it.
Please check:
- do you have latest Pipho version installed? You can check it in CHANGELOG.txt.
- is PIPHO_SORT_IMAGES_ENABLED set to true and PIPHO_SORT_IMAGES_REVERSE to false
- try are sort options working OK with test gallery which comes with Pipho
need help with an error
September 20, 2009 by gautham (not verified), 24 weeks 2 days ago
Comment id: 51
i have uploaded your files on three different service providers web site all of them are running php5
every single site i try to open index.php i get the following error
Failed to save image [photos/test/resized/-thumb-75.jpg][2]
Failed to save image [photos/test/resized/App_Store_Badge_EN-thumb-75.png][3]
i am very new to php
please tell me what i am doing wrong or what changes i need to make for it to work
photos folder has to be writable by php
September 21, 2009 by Tole, 24 weeks 2 days ago
Comment id: 52
Your photos folder is not writable by php.
You can fix it from command prompt by running the chmod command as described in article.
If you are not familiar with command line, you can set write permissions from ftp client too. Just remember to set it recursevly.
Or you can just contact your server support and they'll set it in a minute.
Tole
Pipho typo
September 6, 2009 by GeoNomad (not verified), 26 weeks 3 days ago
Comment id: 43
FYI, there is a typo at line 92 of index.php - or at least I needed a change to make it work for me:
<?php echo $gallery->title ?>
works
<?= $gallery->title ?>
displayed title ?> on the thumbnails page.
I am not familiar with the <?= construct, so perhaps it is some php that is less than universal...
Awesome package! Many thanks for making it available. I hope to put it to good use.
After 15 minutes I am already compiling a wish list:
1. pull captions from exif
2. or - automatically create empty caption files when generating the reduced images so they can be edited. Perhaps with a default title.
3. Option to fade caption in as new slide arrives, then out after some settable delay
4. Endless loop option on slide show.
5. |<-- and -->| to start and end.
6. Automatically generate a manifest file so whole show can be saved for offline viewing.
Apologies if some of these features are there already and I missed them. I have only begun to explore...
Cheers,
Peter
JAIPHO Slideshow Offline
September 7, 2009 by GeoNomad (not verified), 26 weeks 1 day ago
Comment id: 46
As promised, I have made a page with a beta version of the code to make your PIPHO created slideshow run on an iPhone without an internet connection.
As I have put this up in a hurry, I recommend it only for those who know a bit about what they are doing - there is obviously some danger involved in being a pioneer!
benlo.com/jaipho contains the code and a bit of explanation.
You can try loading testoffline.html from your iPhone for the sample show in a form that will stay resident if you save it to the Home Screen on your iPhone or iPod Touch.
I look forward to some feedback from those who try it.
Not a typo, but will be changed
September 7, 2009 by Tole, 26 weeks 1 day ago
Comment id: 45
There is a php config value short_open_tag which enables the short echo syntax. I never encountered php installation with that feature turned off. Anyway I'll change it in future versions.
Regarding wish list, dude, it really rocks. Great ideas, and I'll certainly include it in next versions.
Thanks
Felt like a bit of coding
September 7, 2009 by GeoNomad (not verified), 26 weeks 2 days ago
Comment id: 44
Felt like a bit of coding this afternoon, so I did #2 and #6.
Now I need a nice icon for jaipho slide shows. Although right now it is not bad. When you bookmark it to the Home Screen, it uses part of the photo being displayed.
I can disconnect from the web and the slide show still works beautifully. Just like a native app. All generated automatically with one php script.
I will send you the code later so you can integrate it more prettily if you like, or I can make it available on my own site if you prefer. Just want to tidy up a bit.
Once again, thanks for making such a wonderful and inspiring tool and such nice clean code to work with.
Peter
RE: Felt like a bit of coding
September 7, 2009 by Tole, 26 weeks 1 day ago
Comment id: 47
Great man. I'm specially interested in #6. I plan to put a "Mods" page, and this could be nice one for starting it. And also, I don't have anything against publishing on other sites. I'll gladly link it.
I'm glad that you like coding standard. I'm quite proud on it, and I'll try to improve it's quality even more in future.
Tole
rate the image
August 27, 2009 by Anonymous (not verified), 27 weeks 5 days ago
Comment id: 37
is it possible to make a rating system, so people can rate the image?
Re: rate the image
August 28, 2009 by Tole, 27 weeks 4 days ago
Comment id: 39
No I do not have plans to support rating in close future.
is it possible to do, or
August 30, 2009 by Anonymous (not verified), 27 weeks 2 days ago
Comment id: 41
is it possible to do, or maybe i can pay you to do it?
Yes it is possible
August 31, 2009 by Tole, 27 weeks 1 day ago
Comment id: 42
And, how hard it would be? It depends what are your specific requirements.
If you're satisfied with only voting, it can be done I think not to hard (vote button on top toolbar, on click opens the new page with submit form, and after submission back to Jaipho page)
But, if you want to make it fancy too, it would complicate it a bit more (popup with stars for example).
Anyhow, I prefer that you do it yourself, and I'll give you a hand in it, for free.
Please contact me on contact form with a little bit more specified requirement http://www.jaipho.com/contact
Any news in the raking system
November 15, 2009 by Pepe Gonzalez (not verified), 16 weeks 3 days ago
Comment id: 70
Hi
I was just wondering if anything has been done with the raking system. I would be interested too.
Thanks
RE: Any news in the raking system
November 16, 2009 by Tole, 16 weeks 2 days ago
Comment id: 71
No, almost nothing was done on that matter. We exchanged few mails, and than it stopped.
Same image twice in test gallery
August 12, 2009 by Anonymous (not verified), 30 weeks 19 hours ago
Comment id: 27
Great work, only problem is that when i go to actually view the test gallery I see the first image twice instead of seeing both images. Just to verify, I added a new gallery of my own with 3 pictures and they all show up as the first one.
Any ideas?
Only error getting is:
[Tue Aug 11 16:41:47 2009] [error] [client 192.168.0.73] PHP Notice: Undefined index: filename in /var/www/html/iphonepic/library/Pipho/FileManager.php on line 190
RE: Same image twice in test gallery
August 12, 2009 by Tole, 30 weeks 13 hours ago
Comment id: 28
Strange indeed. Check this things:
- is the GD library installed?
- are there any strange files in your photo folder (windows thmbs file, cvs files ....). you can try to remove all files except images
- look at the generated javascript source (view source in your browser), and check is there something strange in "dao.ReadImage" lines
When you fix it, please report it, so I can add it to Pipho error handling and in article too.
I have the GD library
August 12, 2009 by Anonymous (not verified), 29 weeks 6 days ago
Comment id: 29
I have the GD library installed. I am only using the Test folder that comes the install. Below is what is the in the page source:
// load images
var dao = new Jph_Dao();
dao.ReadImage( 0,'photos/test/resized/-slide-480.jpg','photos/test/resized/-thumb-75.jpg','','');
dao.ReadImage( 1,'photos/test/resized/-slide-480.jpg','photos/test/resized/-thumb-75.jpg','','');
var app = new Jph_Application( dao);
app.Init();
app.Run();
I also see the following in my http error log:
PHP Notice: Undefined index: filename in /var/www/html/iphonepic/library/Pipho/FileManager.php on li ne 184
RE: Same image twice in test gallery
February 25, 2010 by Jesse (not verified), 1 week 6 days ago
Comment id: 121
I had the same problem and the same symptoms. Turns out my installed version of PHP was 5.1.6. After upgrading to version 5.3.1, it now works properly.
Still looks odd
August 14, 2009 by Tole, 29 weeks 4 days ago
Comment id: 30
First, sorry on slower response, I was on trip.
Back on business.
If you look better at lines you pasted, you can see that your image file names are missing. The read image line should look like this:
dao.ReadImage( 0,'photos/test/resized/myimagename-slide-480.jpg','photos/test/resized/myimagename-thumb-75.jpg','','');
I still don't understand what is causing it. I tried to reproduce it on my system with no success. So, we'll have to trace it a little bit more.
Here are few points you should check or try out:
- try to use it with default php.ini
- try to set const value PIPHO_SORT_IMAGES_ENABLED to false.
- check $file variable value received from readdir function in Pipho_FileManager::_getGalleryImagesList()
....
echo $file.'
';
$images[] = $file;
....
- in linux console, try to chmod recursively your photos folder to 777
- what PHP version are you using? Pipho is tested with 5.2
syntax error
July 7, 2009 by Marcio (not verified), 35 weeks 1 day ago
Comment id: 12
Hello, it looks like your script is really good, but I uploaded it to my site and when I tried to access the index.php (to see the test folder images) I got this message:
Parse error: syntax error, unexpected '{' in /mnt/w0503/d20/s33/b02d2ed2/www/neverlopez.com/pipho/index.php on line 24
Am I missing something?
Thanks
here it is - you probably know it ; )
PHP5
July 12, 2009 by Marcio (not verified), 34 weeks 2 days ago
Comment id: 14
Yes you're right, I changed the settings in the web server and now it's working. Thank you very much.
Pipho reqquires PHP 5
July 10, 2009 by Tole, 34 weeks 5 days ago
Comment id: 13
Hi Marcio,
It seems that you are trying to run Pipho on PHP4.
First of all : thanks for
June 6, 2009 by Anonymous (not verified), 39 weeks 4 days ago
Comment id: 8
First of all : thanks for your great work.
One thing i don't understand is the following:
"- index.php in download package handles only one gallery at the time. So remember to set or provide at any way value for $gallery_id variable. gallery_id is actually a folder name."
Does this mean that at the moment pipho can just handle one gallery but there will be support for several galleries in the future ?
Running multiple galleries
June 7, 2009 by Tole, 39 weeks 2 days ago
Comment id: 9
I'm glad you like it, and thanks for interesting question.
Yes, that feature will be added, but I'm not sure when. It will try to follow original iPhone Photos design and functionality, and probably, it will be built on iUI.
Right now, there is already getGalleries() method in Pipho_FileManager which will return all galleries from your photos folder. So for this time, it should be easy to add the required functionality to your existing system.
Vertical images coming out Landscape
August 8, 2009 by NZ (not verified), 30 weeks 4 days ago
Comment id: 19
I got it to work, but all my Vertical images are coming out Landscape.
How do I fix this?
Thanks,
Norm
Vertical images coming out Landscape
August 9, 2009 by Tole, 30 weeks 3 days ago
Comment id: 21
Can you please explain it little bit more or post a link to example?
You might want to try this.
June 11, 2009 by Anonymous (not verified), 38 weeks 5 days ago
Comment id: 10
If you change a line in the index.php you can have separate urls for different gallerys.
If you change this line:
$gallery_id = isset( $_GET['gallery_id']) ? $_GET['gallery_id'] : 'test';
to this:
if (isset($_GET['gallery_id'])) {$gallery_id = $_GET['gallery_id'];}
You can then have separate urls:
www.example.com/photos/?gallery_id=test3
**Note that /photos/ is the folder where your index.php is and test3 is the folder for the gallery.
I hope that helps. Again thanks for making this php!!!
Grazie
May 15, 2009 by Riccardo Grosso (not verified), 42 weeks 4 days ago
Comment id: 5
Thanks for your excellent work, this is the solution I was looking for a long time.
Riccardo