SitePoint Sponsor

User Tag List

Page 1 of 22 1234511 ... LastLast
Results 1 to 25 of 767

Hybrid View

  1. #1
    ********* Articles ArticleBot's Avatar
    Join Date
    Apr 2001
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Discussion thread for Build An Automated PHP Gallery System In Minutes

    This is a dedicated thread for discussing the SitePoint article 'Build An Automated PHP Gallery System In Minutes'

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is something I've been meaning to do for a while. No doubt I'll be using this tutorial when I do!

    Thanks

    -Sam
    Sam Hastings

  3. #3
    SitePoint Member
    Join Date
    May 2003
    Location
    Waddinxveen
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Some minor points:
    1) There is a small bug in upload.php:

    if($size[0] > $size[1])
    {
    $thumbnail_width = 100;
    $thumbnail_height = (int)(100 * $size[0] / $size[1]);
    }
    else
    {
    $thumbnail_width = (int)(100 * $size[0] / $size[1]);
    $thumbnail_height = 100;
    }

    should be:

    if($size[0] > $size[1])
    {
    $thumbnail_width = 100;
    $thumbnail_height = (int)(100 * $size[1] / $size[0]);
    }
    else
    {
    $thumbnail_width = (int)(100 * $size[0] / $size[1]);
    $thumbnail_height = 100;
    }


    2) Adding your own design in design.inc.php doesn't work. Reason is some missing lines in viewgallery.php:

    $result_final

    should be:

    $design_header
    $result_final
    $design_footer

    Apart from this it is a nice article and indeed a timesaver
    Thanks

  4. #4
    SitePoint Enthusiast mayank's Avatar
    Join Date
    Jul 2003
    Location
    India
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    firstly, thanks for comments to all ...

    1) There is a small bug in upload.php:
    it looks ok ... if you notice in both cases i am taking one dimension as constant and calculating the other on basis of its aspect ratio ... so in the case where the image is wide, i am taking the width as constant, e.g. 100 and calculating its height; vice-versa for the tall image.


    Reason is some missing lines in viewgallery.php
    well i didn't write the code for design inclusion in viewgallery.php for that matter in any of the scripts; becuase i didn't wanted the code to look complex. In the paragraph for the desgin section i have mentioned that it will be required to add the $design_header & $design_footer before output, in this case $result_final ...


    Quote Originally Posted by article
    add the variables $design_header and $design_footer in appropriate locations.
    its possible ...

    < S-Point Articles :: Albinator :: mgZhome :: Beyond illusions />

  5. #5
    SitePoint Member
    Join Date
    May 2003
    Location
    Waddinxveen
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I missed the paragraph for the design section, my fault.

    I am sorry but I don't agree with your remark about creating the thumbnails. In my view the code is not correct here.
    Take a picture with size 640x480.
    Original code:
    Landscape: size[0] = 640, size[1] = 480, thumbnail_width = 100, thumbnail_height = 133 (wrong aspect ratio, image looking weird)
    Portrait: size[0] = 480, size[1] = 600, thumbnail_width = 75, thumbnail_height = 100 (correct aspect ratio

    With the corrected code the thumbnails are 100x75 or 75x100 which is as expected.

  6. #6
    SitePoint Addict nabeel's Avatar
    Join Date
    Nov 2002
    Location
    in westchester county, ny
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i've been working a gallery for like a week without a tutorial..just asking questions around. i think ill take a look at this..

  7. #7
    SitePoint Enthusiast mayank's Avatar
    Join Date
    Jul 2003
    Location
    India
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i take my words back, you are right. I was looking at the code i had and not the one i wrote in the article (a typo). Somehow i missed your point ... thanks for correcting


    btw, i was considering to add some code to the article,

    Scenario: If you want to limit the size of your thumbnail to its width x height ... e.g. you don't a thumbnail for a wide image to be bigger than 100x75 and thumbnail for a tall image to be bigger than 75x100

    then the following code could be used:

    PHP Code:
            // Settings
            
    $Config_tbwidth_wide 100// width of wide image
            
    $Config_tbheight_wide 75// height of wide image

            
    $Config_tbwidth_tall 75// width of tall image
            
    $Config_tbheight_tall 100// height of tall image


            // The code
            
    if($size[0] > $size[1])
            {
                
    $thumbnail_width $Config_tbwidth_wide;
                
    $thumbnail_height = (int)($Config_tbwidth_wide $size[1] / $size[0]);

                if(
    $thumbnail_height $Config_tbheight_wide)
                {
                    
    $thumbnail_height $Config_tbheight_wide;
                    
    $thumbnail_width = (int)($Config_tbheight_wide $size[0] / $size[1]);
                }
            }
            else
            {
                
    $thumbnail_width = (int)($Config_tbheight_tall $size[0] / $size[1]);
                
    $thumbnail_height $Config_tbheight_tall;

                if(
    $thumbnail_width $Config_tbwidth_tall)
                {
                    
    $thumbnail_width $Config_tbwidth_tall;
                    
    $thumbnail_height = (int)($Config_tbwidth_tall $size[1] / $size[0]);
                }
            } 

    thought it might be useful ...
    its possible ...

    < S-Point Articles :: Albinator :: mgZhome :: Beyond illusions />

  8. #8
    This is all Mumbo Jumbo Amit's Avatar
    Join Date
    Oct 2001
    Location
    New Delhi, India
    Posts
    277
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great article! How about a sequel ...

  9. #9
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just look to see if there isn't another typo in there though

  10. #10
    SitePoint Enthusiast mayank's Avatar
    Join Date
    Jul 2003
    Location
    India
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sure i will look out those errors this time ...
    its possible ...

    < S-Point Articles :: Albinator :: mgZhome :: Beyond illusions />

  11. #11
    phpLD Fanatic bronze trophy dvduval's Avatar
    Join Date
    Mar 2002
    Location
    Silicon Valley
    Posts
    3,626
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    What about the problem with GIF images brought up in this thread?
    http://www.sitepointforums.com/showt...hreadid=122217

  12. #12
    Super Ninja Monkey Travis's Avatar
    Join Date
    Dec 2001
    Location
    Sioux City, Iowa
    Posts
    691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You cannot use GIF images with the GD library anymore, due to copyright issues.
    Travis Watkins - Hyperactive Coder
    My Blog: Realist Anew
    Projects: Alacarte - Gnome Menu Editor

  13. #13
    SitePoint Enthusiast mayank's Avatar
    Join Date
    Jul 2003
    Location
    India
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes the official versions of GD won't support GIF ... though there are some modified (older) versions of GD which do support GIF but as Travis said they are in violation of the copyright.
    its possible ...

    < S-Point Articles :: Albinator :: mgZhome :: Beyond illusions />

  14. #14
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mayank
    yes the official versions of GD won't support GIF ... though there are some modified (older) versions of GD which do support GIF but as Travis said they are in violation of the copyright.
    the patent has expired and I seem to recall that gif support is being reintroduced into the bundled GD library , perhaps as early as 4.3.3 ?

  15. #15
    This is all Mumbo Jumbo Amit's Avatar
    Join Date
    Oct 2001
    Location
    New Delhi, India
    Posts
    277
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That would be great ...

  16. #16
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope GD could legally support GIF at the moment as the patent has expired although as stated on the GD website earlier this year there is to be no GIF support until early 2004 for some reason or other that I cannot remember...

    Though I think they're waiting on something or other before they release the GIF support in the current GD releases... ?

  17. #17
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr Livingston
    Nope GD could legally support GIF at the moment as the patent has expired although as stated on the GD website earlier this year there is to be no GIF support until early 2004 for some reason or other that I cannot remember...

    Though I think they're waiting on something or other before they release the GIF support in the current GD releases... ?
    Patent has expired in the U.S. The later date is when the Patent expires world wide (IIRC).
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  18. #18
    SitePoint Member
    Join Date
    Oct 2003
    Location
    York, UK
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    imagemagick users?

    is anyone out there using this gallery with imagemagick?

    my gallery is uploading the photos fine, but the thumbnails aren't being generated properly... well, they're not being generated at all...

    is anyone else using imagemagick to render the thumbnails and if so can i please see your upload.php script so i can see where i'm going wrong?

    thanks,

    jonic.

  19. #19
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb

    Hey all, this looks pretty cool and I'm going to get started - but I was wondering if anyone has thought of/developed code for an image moderation tool. I was looking for something similar to how the wordpress comment mod works. Example:

    1) User uses your web based upload page to submit a photo
    2) you are alerted via email that a user has submitted a photo and it awaits moderation
    3) you log on to the moderation page and see the image(s) awaiting moderation
    4) you click approve or yes
    5) the photo is automatically posted/ingested into the db and posted on your site
    OR - you click no, and the photo is deleted.

    Any thoughts?

    Thanks,
    Adam

  20. #20
    Super Ninja Monkey Travis's Avatar
    Join Date
    Dec 2001
    Location
    Sioux City, Iowa
    Posts
    691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr Livingston
    Nope GD could legally support GIF at the moment as the patent has expired although as stated on the GD website earlier this year there is to be no GIF support until early 2004 for some reason or other that I cannot remember...

    Though I think they're waiting on something or other before they release the GIF support in the current GD releases... ?
    Its because thats when the patent expires in the EU, if I remember correctly.
    Travis Watkins - Hyperactive Coder
    My Blog: Realist Anew
    Projects: Alacarte - Gnome Menu Editor

  21. #21
    Fully Sweet Car noddy's Avatar
    Join Date
    Aug 2002
    Location
    Perth, Western Australia
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah great article im working through it but having a coupla issues I'm working through

  22. #22
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What kind of issues ?

  23. #23
    Fully Sweet Car noddy's Avatar
    Join Date
    Aug 2002
    Location
    Perth, Western Australia
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm getting this error on line 34 of upload.php
    Fatal error: Maximum execution time of 60 seconds exceeded in /home/nathanr/public_html/radiorallyv2/pic/upload.php on line 34
    this is line 34
    PHP Code:
    while($counter <= count($photos_uploaded)) { 
    and this is the block of code around line 34
    PHP Code:
     while($counter <= count($photos_uploaded)) {
    if(
    $photos_uploaded['size'][$counter] > 0) {
    if(!
    array_key_exists($photos_uploaded['type'][$counter], $photo_types)) {
    $result_final .= 'File ' . ($counter 1) . ' is not a photo<br />';
    } else {
    // Great the file is an image, we will add this file
    }
    }

    this is my whole script
    PHP Code:
    <? include_once("../header.php" ); ?> 
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr> 
    <td colspan="2"><img src="../img/banner2.jpg" border="0" vspace="0" hspace="0" name="banner"></td>
    </tr>
    <tr> 
    <td valign=top width=16% class="menu"> 
    <? include_once("../menu2.php" ); ?>
    </td>
    <td width="*%" valign=top> 
    <?
    // include the database specific information
    include_once("../inc/db.php" );
    // make a connection to the rrc database
    dbConnect();
    $images_dir 'photos';
    // Fetch the image array sent by preuploaed.php
    $photos_uploaded $_FILES['photo_filename'];
    // Fetch the image caption array
    $photo_captions $_POST['photo_captions'];
    $photo_types = array(
    'image/pjpeg' => 'jpg',
    'image/jpeg' => 'jpg',
    'image/gif' => 'gif',
    'image/bmp' => 'bmp',
    'image/x-png' => 'png'
    );
    while(
    $counter <= count($photos_uploaded) ) {
    if(
    $photos_uploaded['size'][$counter] > 0) {
    if(!
    array_key_exists($photos_uploaded['type'][$counter], $photo_types)) {
    $result_final .= 'File ' . ($counter 1) . ' is not a photo<br />';
    } else {
    // Great the file is an image, we will add this file
    }
    }
    }
    $query "INSERT INTO gallery_photos (photo_filename, photo_caption, photo_category) VALUES ('0','" $photo_captions[$counter] . "','" $_POST['category'] . "')";
    mysql_query($query);
    $new_id mysql_insert_id(); // New Id generated
    // Get the filetype of the uploaded file
    $filetype $photos_uploaded['type'][$counter];
    // Get the extension for the new name
    $extension $known_photo_types[$filetype];
    // Generate a new name
    $filename "$new_id.$extension";
    // let's update the filename now
    $query "UPDATE gallery_photos SET photo_filename = '$filename' WHERE photo_id = '$new_id'";
    mysql_query($query);
    copy($photos_uploaded['tmp_name'][$counter], $images_dir '/' $filename);
    $size GetImageSize($images_dir "/" $filename);
    // Settings 
    $Config_tbwidth_wide 100// width of wide image 
    $Config_tbheight_wide 75// height of wide image 
    $Config_tbwidth_tall 75// width of tall image 
    $Config_tbheight_tall 100// height of tall image 

    // The code 
    if($size[0] > $size[1]) 

    $thumbnail_width $Config_tbwidth_wide
    $thumbnail_height = (int)($Config_tbwidth_wide $size[1] / $size[0]); 
    if(
    $thumbnail_height $Config_tbheight_wide

    $thumbnail_height $Config_tbheight_wide
    $thumbnail_width = (int)($Config_tbheight_wide $size[0] / $size[1]); 


    else 

    $thumbnail_width = (int)($Config_tbheight_tall $size[0] / $size[1]); 
    $thumbnail_height $Config_tbheight_tall
    if(
    $thumbnail_width $Config_tbwidth_tall

    $thumbnail_width $Config_tbwidth_tall
    $thumbnail_height = (int)($Config_tbwidth_tall $size[1] / $size[0]); 


    $gd_function_suffix = array (
    'image/pjpeg' => 'JPEG',
    'image/jpeg' => 'JPEG',
    'image/gif' => 'GIF',
    'image/bmp' => 'WBMP',
    'image/x-png' => 'PNG'
    );
    $function_suffix $gd_function_suffix[$filetype];
    $function_to_read 'ImageCreateFrom' $function_suffix;
    $function_to_write 'Image' $function_suffix;
    // Read the source file
    $source_handle $function_to_read($images_dir '/' $filename );
    if (
    $source_handle) {
    // Let's create a blank image for the thumbnail
    $destination_handle ImageCreate($thumbnail_width$thumbnail_height);

    // Now we resize it
    ImageCopyResized($destination_handle$source_handle0000$thumbnail_width$thumbnail_height$size[0], $size[1]);
    }
    // Lets save the thumbnail
    $function_to_write($destination_handle$images_dir '/tb_' $filename);
    ImageDestroy($destination_handle);
    ?>
    </td>
    </tr>
    </table>
    <? include_once("../footer.php" ); ?>
    Last edited by noddy; Aug 11, 2003 at 18:36.

  24. #24
    SitePoint Enthusiast mayank's Avatar
    Join Date
    Jul 2003
    Location
    India
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The while loop will never end as the counter is not being incremented. It looks like the code is not correctly formulated. You might want to download the archive with the article, from here

    also, if you are uploading many images at once, you would like to reset the default execution time limit of 30 seconds,

    PHP Code:
    set_time_limit(0); 
    its possible ...

    < S-Point Articles :: Albinator :: mgZhome :: Beyond illusions />

  25. #25
    SitePoint Member
    Join Date
    Dec 2003
    Location
    devon UK
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    photo_caption to display with the Thumbnail Listing

    Hi,

    This tutorial is great, easy to follow and i got it working first time. I am a newB to PHP and itís nice to find something that is both well explained and that acutely worked without having to spend hours debugging.

    Q. How can I get the photo_caption to display with the Thumbnail Listing?

    Hope you can help!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •