SitePoint Sponsor

User Tag List

Page 1 of 31 1234511 ... LastLast
Results 1 to 25 of 767
  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
    Anonymous
    SitePoint Community Guest
    Good article, but the link for the ZIP 'in the downloadable archive' is 404

  3. #3
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not a bad article to introduce us all to the wonderful world of uploading our dirty negs to the Net

    Seriously though for beginners or for those looking to getting started with PHP this would be a great project to build up from ...

  4. #4
    SitePoint Enthusiast zeedoo's Avatar
    Join Date
    Jan 2002
    Location
    India
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    very nicely structured tutorial ...

  5. #5
    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

  6. #6
    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

  7. #7
    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 />

  8. #8
    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.

  9. #9
    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..

  10. #10
    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 />

  11. #11
    SitePoint Enthusiast zeedoo's Avatar
    Join Date
    Jan 2002
    Location
    India
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey cool something i wanted ...

  12. #12
    SitePoint Member
    Join Date
    Aug 2003
    Location
    My Computer
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cool! i like it ...

  13. #13
    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 ...

  14. #14
    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

  15. #15
    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 />

  16. #16
    phpLD Fanatic bronze trophy dvduval's Avatar
    Join Date
    Mar 2002
    Location
    Silicon Valley
    Posts
    3,627
    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

  17. #17
    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

  18. #18
    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 />

  19. #19
    ********* 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 ?

  20. #20
    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 ...

  21. #21
    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... ?

  22. #22
    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

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

  24. #24
    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.

  25. #25
    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 />


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
  •