Re: [PHP] Thumbnail through PHP RSS parser
On Jul 29, 2008, at 6:33 AM, Lyubomir Tsvetanov wrote: Hello, folks! I'm trying to parse RSS feed and display it on my own page. MagpieRSS looks good enough for me, but I have a little problem. http://magpierss.sourceforge.net/ I want to display not only the title and description of each article, but the thumbnail as well. For example, I tried to do that with this feed. http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml Everything is alright with the title and the description, but I can't do the thumbnail thing. What I've tried is the following: foreach ($rss->items as $item ) { $title = $item[title]; $url = $item[link]; $description = $item[description]; $thumbnail = $item['media:thumbnail']; echo "$title"; echo $description; echo ""; } As I said before, the other things are fine, but it's not showing the thumbnail. This is the structure: txt txt Try that instead. ~Phil And the following line of the php code returns blank result. (probably because we require parameter of media:thumbnail, not the value 'inside' it): $thumbnail = $item['media:thumbnail']; So I am interested in that parameter url, but I do not know how can we get it. Thanks in advance for any help! "Personally, most of my web applications do not have to factor 13.7 billion years of space drift in to the calculations, so PHP's rand function has been great for me..." ~S. Johnson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] thumbnail of webpage
I may have found something, a perl script that with all the appropriate pieces turns a page into a jpg image. http://marginalhacks.com/Hacks/html2jpg/ from there resizing using GD is a snap. Warren Vail -Original Message- From: Vail, Warren [mailto:[EMAIL PROTECTED] Sent: Friday, September 17, 2004 6:48 PM To: 'Jason Davidson'; Michael Mao; [EMAIL PROTECTED] Subject: RE: [PHP] thumbnail of webpage I have been looking into this over the last week and have come up blank as well. Doing this manually is simple, point your browser to your URL, and in windows use to copy an image of the rendering in the browser to the scratch-pad, then paste the image into a tool like paint to cut out the part of the image you want, and use the skew/stretch tool in paint to create the thumbnail (GD is a good solution as well) saving the file as a jpg image. The difficulties with php is that opening the URL with fopen or using CURL allows getting the content of a page in html form, but provides no bitmap rendering of all that, let alone allowing JavaScript to alter the presentation as it would in a browser. What would be useful, if there were a way to open the URL in an IFRAME, and with JavaScript somehow capture a bitmap of the rendering of the web page, perhaps encoding the bitmap as mod64 characters and placing the result in a textarea for posting as input to a php script. This was the best solution that I could come up with but I don't have the skills to make this happen, yet. Question for anyone here, is does this sound like a path that might work? Can JavaScript access the rendered content of a webpage in window bitmap form? In my travels, someone had suggested coding something using mozilla and invoking it from a php script, but no one has done this yet that I can determine. Warren Vail -Original Message- From: Jason Davidson [mailto:[EMAIL PROTECTED] Sent: Friday, September 17, 2004 6:08 PM To: Michael Mao; [EMAIL PROTECTED] Subject: Re: [PHP] thumbnail of webpage First, im not sure how you would capture a snapshot of the page, sinse the page is rendered by the browser, and php is completely server side. Possibly there is a way to fopen a page or something, but... i dunno.. as for making thumbnail, using the gd extension, is quite easy. check the manual for GD. Jason "Michael Mao" <[EMAIL PROTECTED]> wrote: > > Is there a way to capture a snapshot of a html page and save it as a > jpg > using php? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail of webpage
Great link. This tool is exactly what I'm looking for. Thanks! On Mon, 20 Sep 2004 08:01:15 -0500 (EST), Ed Curtis <[EMAIL PROTECTED]> wrote: > > If you have a Linux box available here's something to try although it > does have some required software. > > http://www.babysimon.co.uk/khtml2png/index.html > > There is also a link on the site for a commercial product for Windows that > does the same thing. > > I can't endorse either one as I have not used them. Just giving the > information. > > Ed > > > > > On Sat, 18 Sep 2004, raditha dissanayake wrote: > > > Michael Mao wrote: > > > > > Is there a way to capture a snapshot of a html page and save it as a > > > jpg using php? > > > > > This is something that's very very hard to do with PHP but can be easily > > done with Java. > > > > > > > > > > -- > > Raditha Dissanayake. > > > > http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload > > Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader > > Graphical User Inteface. Just 128 KB | with progress bar. > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail of webpage
Stefan Holmes wrote: -Original Message- From: raditha dissanayake [mailto:[EMAIL PROTECTED] Sent: 18 September 2004 03:22 To: Michael Mao Cc: [EMAIL PROTECTED] Subject: Re: [PHP] thumbnail of webpage Michael Mao wrote: Is there a way to capture a snapshot of a html page and save it as a jpg using php? This is something that's very very hard to do with PHP but can be easily done with Java. I would guess the easiest way would be to find some external program that retrieves the page and then renders to an image file. I don't offhand the names of any utils that do this, but I'm sure there must be at least /one/ available! if you're feeling extremely ambitiious, how about taking the gecko source and rendering the result to a PDF or JPG file instead of the screen? come on guys get with it. Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] thumbnail of webpage
> -Original Message- > From: raditha dissanayake [mailto:[EMAIL PROTECTED] > Sent: 18 September 2004 03:22 > To: Michael Mao > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP] thumbnail of webpage > > Michael Mao wrote: > > > Is there a way to capture a snapshot of a html page and save it as a > > jpg using php? > > > This is something that's very very hard to do with PHP but can be easily > done with Java. I would guess the easiest way would be to find some external program that retrieves the page and then renders to an image file. I don't offhand the names of any utils that do this, but I'm sure there must be at least /one/ available! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] thumbnail of webpage
True, you'd have to run it on the web client end, but you can run IE on the server to access the HTML the server is err..serving. The server can also be a client, in other words. So your server can generate a thumbnail of what it's serving out by acting as a client for a second. As long as their security allows them to execute IE or interface with it and possibly the windows API. There are complexities, but it's the path I would explore if I had to create my own thumbnailing system (in the absence of some quick and easy utility that already did it). -TG > -Original Message- > From: raditha dissanayake [mailto:[EMAIL PROTECTED] > Sent: Monday, September 20, 2004 12:28 PM > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP] thumbnail of webpage > > > Gryffyn, Trevor wrote: > > >Some great recommendations, but my first thought is > wondering if you can > >interface with IE via COM or something. Or open the URL > via IE and use > >the Windows API to do a PRINT SCREEN or ALT-PRINT SCREEN to > capture it > >to the clipboard and do something funny that way. > > > > > > > Good ideas but then you would need to run PHP on the client > side and not on the server (assuming of course that the original > poster is not runnig his server on an OS that does not have any > security features). > > There was a similar question on 'the list' and someone suggested and > image magick would be able to do this. > > > -- > Raditha Dissanayake. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail of webpage
Gryffyn, Trevor wrote: Some great recommendations, but my first thought is wondering if you can interface with IE via COM or something. Or open the URL via IE and use the Windows API to do a PRINT SCREEN or ALT-PRINT SCREEN to capture it to the clipboard and do something funny that way. Good ideas but then you would need to run PHP on the client side and not on the server (assuming of course that the original poster is not runnig his server on an OS that does not have any security features). There was a similar question on 'the list' and someone suggested and image magick would be able to do this. -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 128 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] thumbnail of webpage
Some great recommendations, but my first thought is wondering if you can interface with IE via COM or something. Or open the URL via IE and use the Windows API to do a PRINT SCREEN or ALT-PRINT SCREEN to capture it to the clipboard and do something funny that way. If I had time right now, I'd love to dig into this, but I wanted to at least share the thought in case it helped. Good luck! Let us know if you find a good way to do this via PHP. -TG > -Original Message- > From: Michael Mao [mailto:[EMAIL PROTECTED] > Sent: Friday, September 17, 2004 7:54 PM > To: [EMAIL PROTECTED] > Subject: [PHP] thumbnail of webpage > > > Is there a way to capture a snapshot of a html page and save > it as a jpg > using php? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail of webpage
If you have a Linux box available here's something to try although it does have some required software. http://www.babysimon.co.uk/khtml2png/index.html There is also a link on the site for a commercial product for Windows that does the same thing. I can't endorse either one as I have not used them. Just giving the information. Ed On Sat, 18 Sep 2004, raditha dissanayake wrote: > Michael Mao wrote: > > > Is there a way to capture a snapshot of a html page and save it as a > > jpg using php? > > > This is something that's very very hard to do with PHP but can be easily > done with Java. > > > > > -- > Raditha Dissanayake. > > http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload > Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader > Graphical User Inteface. Just 128 KB | with progress bar. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail of webpage
On Fri, 2004-09-17 at 22:22, raditha dissanayake wrote: > Michael Mao wrote: > > > Is there a way to capture a snapshot of a html page and save it as a > > jpg using php? > > > This is something that's very very hard to do with PHP but can be easily > done with Java. Have not tried this but how about using 'import' which is part of the ImageMagick package? According to the man page: NAME import - capture some or all of an X server screen and save the image to a file. SYNOPSIS import [ options ... ] file DESCRIPTION Import reads an image from any visible window on an X server and out-puts it as an image file. You can capture a single window, the entire screen, or any rectangular portion of the screen. Use display for redisplay, printing, editing, formatting, archiving, image processing, etc. of the captured image. The target window can be specified by id, name, or may be selected by clicking the mouse in the desired window. If you press a button and then drag, a rectangle will form which expands and contracts as the mouse moves. To save the portion of the screen defined by the rectan- gle, just release the button. The keyboard bell is rung once at the beginning of the screen capture and twice when it completes. -- s/:-[(/]/:-)/g BrianGnuPG -> KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu == gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC Key Info: http://gfx-design.com/keys Linux Registered User #339825 at http://counter.li.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail of webpage
Hi Michael, read this (in italian) http://forum.html.it/forum/showthread.php?s=&threadid=694523&highlight=pillo la+upload - Original Message - From: "Michael Mao" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Saturday, September 18, 2004 1:54 AM Subject: [PHP] thumbnail of webpage > Is there a way to capture a snapshot of a html page and save it as a jpg > using php? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail of webpage
On Saturday 18 September 2004 09:48, Vail, Warren wrote: > I have been looking into this over the last week and have come up blank as > well. A semi-workable was posted in the archives some months ago. Twice. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Ingrate, n.: A man who bites the hand that feeds him, and then complains of indigestion. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail of webpage
> Michael Mao wrote: > > > Is there a way to capture a snapshot of a html page and save it as a > > jpg using php? This is a bit of a hack, but kinda neat if you don't mind setting it up. I'm sure you could use php to call a script anyway. Heh. http://www.livejournal.com/users/brad/2015327.html - Brad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail of webpage
* Thus wrote Michael Mao: > Is there a way to capture a snapshot of a html page and save it as a jpg > using php? As you can see this isn't an easy task. One possiblity is to ask the mozilla/gecko developers if it would be possible to to create a library that would render a page into a bitmap. If that is the case then PHP would be able to do what you need very easily. Curt -- The above comments may offend you. flame at will. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail of webpage
Michael Mao wrote: Is there a way to capture a snapshot of a html page and save it as a jpg using php? This is something that's very very hard to do with PHP but can be easily done with Java. -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 128 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] thumbnail of webpage
I have been looking into this over the last week and have come up blank as well. Doing this manually is simple, point your browser to your URL, and in windows use to copy an image of the rendering in the browser to the scratch-pad, then paste the image into a tool like paint to cut out the part of the image you want, and use the skew/stretch tool in paint to create the thumbnail (GD is a good solution as well) saving the file as a jpg image. The difficulties with php is that opening the URL with fopen or using CURL allows getting the content of a page in html form, but provides no bitmap rendering of all that, let alone allowing JavaScript to alter the presentation as it would in a browser. What would be useful, if there were a way to open the URL in an IFRAME, and with JavaScript somehow capture a bitmap of the rendering of the web page, perhaps encoding the bitmap as mod64 characters and placing the result in a textarea for posting as input to a php script. This was the best solution that I could come up with but I don't have the skills to make this happen, yet. Question for anyone here, is does this sound like a path that might work? Can JavaScript access the rendered content of a webpage in window bitmap form? In my travels, someone had suggested coding something using mozilla and invoking it from a php script, but no one has done this yet that I can determine. Warren Vail -Original Message- From: Jason Davidson [mailto:[EMAIL PROTECTED] Sent: Friday, September 17, 2004 6:08 PM To: Michael Mao; [EMAIL PROTECTED] Subject: Re: [PHP] thumbnail of webpage First, im not sure how you would capture a snapshot of the page, sinse the page is rendered by the browser, and php is completely server side. Possibly there is a way to fopen a page or something, but... i dunno.. as for making thumbnail, using the gd extension, is quite easy. check the manual for GD. Jason "Michael Mao" <[EMAIL PROTECTED]> wrote: > > Is there a way to capture a snapshot of a html page and save it as a > jpg > using php? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail of webpage
First, im not sure how you would capture a snapshot of the page, sinse the page is rendered by the browser, and php is completely server side. Possibly there is a way to fopen a page or something, but... i dunno.. as for making thumbnail, using the gd extension, is quite easy. check the manual for GD. Jason "Michael Mao" <[EMAIL PROTECTED]> wrote: > > Is there a way to capture a snapshot of a html page and save it as a jpg > using php? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thumbnail Problem
On Fri, 13 Aug 2004 15:18:20 +0800 [EMAIL PROTECTED] (Jason Wong) wrote: > On Thursday 12 August 2004 21:05, Me2resh wrote: > > i have a class that generates thumbnails without making actual file on the > > server > > it works good on my local server > > but on my web hosting it gives me " > > Fatal error: Call to undefined function: exif_imagetype() in Need to compile PHP with --enable-exif, althou getimagesize() maight be better alternetive > > /home/me2resh/public_html/furniture/class_THUMB.php on line 58 > > " > > how can i pass this step and make the script works without using this > > undefines function > > Don't use that function? If you want the script to work more or less the same > then replace that function with getimagesize(). > > > here is the class : > > [load of rubbish snipped] > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.biz > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > -- > Search the list archives before you post > http://marc.theaimsgroup.com/?l=php-general > -- > /* > FORTUNE PROVIDES QUESTIONS FOR THE GREAT ANSWERS: #4 > A:Go west, young man, go west! > Q:What do wabbits do when they get tiwed of wunning awound? > */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thumbnail Problem
On Thursday 12 August 2004 21:05, Me2resh wrote: > i have a class that generates thumbnails without making actual file on the > server > it works good on my local server > but on my web hosting it gives me " > Fatal error: Call to undefined function: exif_imagetype() in > /home/me2resh/public_html/furniture/class_THUMB.php on line 58 > " > how can i pass this step and make the script works without using this > undefines function Don't use that function? If you want the script to work more or less the same then replace that function with getimagesize(). > here is the class : [load of rubbish snipped] -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* FORTUNE PROVIDES QUESTIONS FOR THE GREAT ANSWERS: #4 A: Go west, young man, go west! Q: What do wabbits do when they get tiwed of wunning awound? */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail problems
Ninti Systems wrote: I've searched the archives on this and, while I have turned up some tips, they don't seem to solve my problem. I an building a website for an indigenous organisation where jpg images are uploaded, resized to a standard format, and thumbnails also generated at the same time (so that is two resizes for each image). Most of the time this works OK, but there are a lot of pages where many thumbnails are just blacked out, eg: http://waru.org/arakuwaritja.php?p=63 On some pages, all images are blacked out, eg: http://waru.org/arakuwaritja.php?p=36 whereas on others they're all OK, eg: http://waru.org/arakuwaritja.php?p=43 The people in the field taking and uploading the photos insist that the format, color depth, etc, is not changing from photo to photo, and I can't discern any differences. Yet some work, some don't. I read somewhere that memory limitations could cause this, but still, it only happens sometimes and not others. We are on a crowded shared server I think. I'm use ImageCreateTrueColor() after checking with ImageIsTrueColor(), otherwise just ImageCreate(). The initial resizes almost always work (down from 640x480 to 400x300), with the thumbnails it is looking like a 50% failure rate. Try to always use ImageCreateTrueColor() - even if the original has only 255 colors the thumbnails might have more. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail problems
* Thus wrote Ninti Systems ([EMAIL PROTECTED]): > > I read somewhere that memory limitations could cause this, but still, it > only happens sometimes and not others. We are on a crowded shared server > I think. A quick sample of sizes of images does back this thoery up. Most pictures I sampled, the full picture's that resized properly were ~16KB, the black icon images original size were ~24KB - ~35KB I would think that the GD library will complain at some point if there are memory problems, make sure your settings (on the page that generates the thumbnails) has error_reporting(E_ALL), and monitor any errors that occure there. Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail script
Ryan, et al -- ...and then Ryan A said... % % Hey David (my pal with the funny % prefix to replies...:-p ) Hi, Ryan (my ex-logo-drawing-buddy with the non-threading mailer ;-) % Thanks for replying. Sure thing. % % > Why, yes. I call it % > http://web-folio.net/ % % Nice name. Thanks! % % > and it does everything for which you ask and then some. % Kewl, is it free and can i download it and use it on my website? Heh :-) We're selling a service, dude. % % > Just send all of % > your clients to host with me and % > I'll give you a commission ;-) % % Damn, that answers my question, its not free and I cant download and use it % on my website (wa) Yep. % % On a more serious note, nice site mate, but reay steep on the pocket, % $250 setup fee? my pal sets up It's a start. We can see if the market dictates a change. % computers and furnature for a lot less, and $25 a month for 100mb space? I % know porn friendly sites that % charge less and offer more. Reading prices like that made my right hand jump Ah, but it's not just some space we're offering. Go back and look again (and then please tell me how you missed it and what needs to clarified, because it's supposed to be obvious :-) Think like a person definitely *not* on this list. Your average realtor, interior designer, quilter, flower arranger, jewelry maker, painter, or whomever won't know the first thing (well, perhaps, but not the second thing!) about how to put files on a web site or lay out web pages or even what goes into making a web page. What we do is make it incredibly easy to upload and manage pictures, automatically handle the thumbnailing and layout into pages, and give you plenty of space to do it (100M holds about 500 pix). I know dozens of realtors who each paid $1k for a template site (no indivduality there!) with a glamour shot, a couple of buttons, and maybe another picture. Then they pay $700/yr for basic hosting with no extras. Meanwhile, they don't know how to put up pictures, so they have to find students or, worse yet, pay geeks to upload pictures -- and then they only get room for a dozen or so. In the small business market where people want reliable hosting with no worries just like anyone else but don't have a budget for a designer and a big hosting company, $25/mo is cheap. At least, that's the plan ;-) % for the mouse and find the little % x at the top right of my browser and made me reach for a coke because of the % fright I got! :-D *grin* % I'm pretty sure you wont get anyone off the list purchasing an account and % there are a lot of people out there Well, maybe not, but we're not really targeting the people here. I know that I can't compete on raw price (I don't have the investment capital to create a data center that can handle the volume of customers that it would take to do that), and I don't want to sell geeks because I've seen how demanding and bothersome I am :-) The value definitely has to be in the service. % who pay more for _total_ crap, and your service is good sobest of % luck and hope it goes well. Thanks; we do, too. % % % > OK... Having spent quite a bit of time developing our gallery script % > and a bit of looking around at competition, I haven't % > seen anything that % > comes close. % % This sort of an app never really did cross my mind...so i dont know what % your compettion is like, have a couple % of urls? I promise i wont join any of them :-p I don't have 'em handy, I'm afraid. Check hotscripts and the like for any gallery or thumbnail script. % % > In general, though, it's not too tough to check your source % > files and both make the thumbnails and generate their image tags to % > output in the page. % % Yeah, thats what i have been told on the list and off, but I have never % really worked with GD + the image functions Bah. Nor have I; I use ImageMagick :-) % and it seems better to first look around to see if anyone already made this % rather than to try to invent the wheel all over That's a good approach, and a good way to get started quickly. It can bite you in the long run, though. % again, although I agree with Justin saying that while "remaking the wheel" % you will understand the code better and it will % be more specific to your needs. Another problem is I have GD 1 on one server % and GD 2 on another... This is also a good approach, and it can still end up biting you as you grow, so I'm all for the former and then for rewriting from scratch for version two :-) % % I did get a few really helpful souls off the list who sent me code, mainly % for jpg stuff, will try that out. That's why we're all here :-) % % > HTH & HAND & Good luck! % % Sure did, and the same to you dude. Thanks :-) % % Cheers, % -Ryan % HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker
Re: [PHP] thumbnail script
Hey David (my pal with the funny % prefix to replies...:-p ) Thanks for replying. > Why, yes. I call it > http://web-folio.net/ Nice name. > and it does everything for which you ask and then some. Kewl, is it free and can i download it and use it on my website? > Just send all of > your clients to host with me and > I'll give you a commission ;-) Damn, that answers my question, its not free and I cant download and use it on my website (wa) On a more serious note, nice site mate, but reay steep on the pocket, $250 setup fee? my pal sets up computers and furnature for a lot less, and $25 a month for 100mb space? I know porn friendly sites that charge less and offer more. Reading prices like that made my right hand jump for the mouse and find the little x at the top right of my browser and made me reach for a coke because of the fright I got! :-D I'm pretty sure you wont get anyone off the list purchasing an account and there are a lot of people out there who pay more for _total_ crap, and your service is good sobest of luck and hope it goes well. > OK... Having spent quite a bit of time developing our gallery script > and a bit of looking around at competition, I haven't > seen anything that > comes close. This sort of an app never really did cross my mind...so i dont know what your compettion is like, have a couple of urls? I promise i wont join any of them :-p > In general, though, it's not too tough to check your source > files and both make the thumbnails and generate their image tags to > output in the page. Yeah, thats what i have been told on the list and off, but I have never really worked with GD + the image functions and it seems better to first look around to see if anyone already made this rather than to try to invent the wheel all over again, although I agree with Justin saying that while "remaking the wheel" you will understand the code better and it will be more specific to your needs. Another problem is I have GD 1 on one server and GD 2 on another... I did get a few really helpful souls off the list who sent me code, mainly for jpg stuff, will try that out. > HTH & HAND & Good luck! Sure did, and the same to you dude. Cheers, -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail script
Ryan -- ...and then Ryan A said... % % Hi, % Anybody know of a thumbnail script which does either one of the following: [snip] Why, yes. I call it http://web-folio.net/ and it does everything for which you ask and then some. Just send all of your clients to host with me and I'll give you a commission ;-) OK... Having spent quite a bit of time developing our gallery script and a bit of looking around at competition, I haven't seen anything that comes close. In general, though, it's not too tough to check your source files and both make the thumbnails and generate their image tags to output in the page. HTH & HAND & Good luck! :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, "Science and Health" http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! pgp0.pgp Description: PGP signature
Re: [PHP] thumbnail script
Jason Wong wrote: manual > imagejpeg() & siblings You could take a look at the source code for "gallery" for more ideas. Google gallery php or something like that. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail script
On Friday 06 February 2004 10:42, Ryan A wrote: >2. This creates > the thumb dynamically via an img tagbut does not save it...so everytime > a visitor opens up the "portfolio" > it generates the thumbwhich will be a load on the server in the long > run, something that would be cut down > a lot if after it first generated it, it saved the image in some directory. manual > imagejpeg() & siblings -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Any fool can tell the truth, but it requires a man of sense to know how to lie well. -- Samuel Butler */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thumbnail Page
PETCOL typed this on 02/02/2004 03:47 PM: I think I'm having a "Bad Hair Day" I have a table in my database with all my thumbnail filenames in it. My query pull that out, now I want to display the images in a table, I can get it to go down the page row by row, but I want it to say do five columns of different images and then go down the page with different images? Maybe even have Next and Previous at the bottom would be nice. Anyone got a suggestion, other than a good night sleep ;-) Col I won't tell you how to specifically do it, as that's the fun of programming...but I'll give you a few tips. Let's say you have 20 rocks. You want five columns of images, so you would have 4 rows by 5 images. Essentially, you want a table that looks like so: x x x x x x x x x x x x x x x x x x x x First you would build your recordset. Then you would open up a table and begin your first row. How many rocks would you have to count, before you ended your row and started a new row? So, you would need a method of counting where you were in your recordset to know when to close the table row and when to open up a new one. 1 2 3 4 5 6 7 8 9 10 ... -Robby -- #--- # Robby Russell, | Sr. Administrator / Lead Programmer # Command Prompt, Inc. | http://www.commandprompt.com # [EMAIL PROTECTED] | Telephone: (503) 667.4564 #--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail
On Wed, 2004-01-21 at 08:16, Ed Curtis wrote: > > No need to copy+mogrify; just use > > > > convert [options] /path/to/old /path/to/new > > > > instead :-) > > I wasn't aware of that command. This list is great!! Just for clarification, those are not PHP functions, they are programs that are a part of the Image Magick package. And personally, I also think it works much better then GD. -- BrianGnuPG -> KeyID: 0x04A4F0DC | URL: www.gfx-design.com/keys Key Server: pgp.mit.edu == gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC GnuPG: http://gnupg.org http://www.biglumber.com/x/web?qs=0x2C35011004A4F0DC Linux Registered User #339825 at http://counter.li.org signature.asc Description: This is a digitally signed message part
RE: [PHP] thumbnail???
Try this: function Resize_Image($FilePath, $new_w){ $File = fopen($FilePath, "r"); $FileContents = fread($File, filesize($FilePath)); $src= imagecreatefromstring($FileContents); $width = imagesx($src); // Shrink the image to the maximum width // Maintaining aspect ratio if($width > $new_w){ $height = imagesy($src); $aspect_ratio = $height/$width; $new_h = abs($new_w * $aspect_ratio); $img = imagecreatetruecolor($new_w,$new_h); imagecopyresized($img,$src,0,0,0,0,$new_w,$new_h,$width,$height); ob_start(); imagejpeg($img); $FileContents = ob_get_contents(); ob_end_clean(); imagedestroy($img); } return $FileContents; } you can then either save the filecontents as an image, or place it in a database. -Original Message- From: Rafael Alex Cremer [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 20, 2004 5:29 PM To: [EMAIL PROTECTED] Subject: [PHP] thumbnail??? OK, but how? I already use GD, I need to now how to create a thumbnail, somebody now how to use the GD functions to create a thumbnail??? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail
> No need to copy+mogrify; just use > > convert [options] /path/to/old /path/to/new > > instead :-) I wasn't aware of that command. This list is great!! Thanks, Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail
Ed, et al -- ...and then Ed Curtis said... % % Personally, I think Imagemagick's mogrify works alot better. I've been I'm quite happy with IM, too, and use it both within and separate from PHP. % using GD for the past few months and it's very inconsistent on thumbnail % quality even when the quality setting is at maximum. How very interesting... Thanks for the tip. % % The only real problem with mogrify is that you have to copy an image to a % seperate location if you want to keep the original file as it overwrites % the file it's making a thumnail of. No need to copy+mogrify; just use convert [options] /path/to/old /path/to/new instead :-) % % Ed HTH & HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, "Science and Health" http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! pgp0.pgp Description: PGP signature
Re: [PHP] thumbnail
> [snip] > OK, but how? I already use GD, I need to now how to create a thumbnail, > > somebody now how to use the GD functions to create a thumbnail??? > [/snip] > > http://www.php.net/GD Personally, I think Imagemagick's mogrify works alot better. I've been using GD for the past few months and it's very inconsistent on thumbnail quality even when the quality setting is at maximum. The only real problem with mogrify is that you have to copy an image to a seperate location if you want to keep the original file as it overwrites the file it's making a thumnail of. Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail
This works like a charm on JPG, haven't tried it on other files types. This came from the www.php.net function image_createThumb($src,$dest,$maxWidth,$maxHeight,$quality=100) { if (file_exists($src) && isset($dest)) { // path info $destInfo = pathInfo($dest); // image src size $srcSize = getImageSize($src); // image dest size $destSize[0] = width, $destSize[1] = height $srcRatio = $srcSize[0]/$srcSize[1]; // width/height ratio $destRatio = $maxWidth/$maxHeight; if ($destRatio > $srcRatio) { $destSize[1] = $maxHeight; $destSize[0] = $maxHeight*$srcRatio; } else { $destSize[0] = $maxWidth; $destSize[1] = $maxWidth/$srcRatio; } // path rectification if ($destInfo['extension'] == "gif") { $dest = substr_replace($dest, 'jpg', -3); } // true color image, with anti-aliasing $destImage = imageCreateTrueColor($destSize[0],$destSize[1]); //CAE imageAntiAlias($destImage,true); // src image switch ($srcSize[2]) { case 1: //GIF $srcImage = imageCreateFromGif($src); break; case 2: //JPEG $srcImage = imageCreateFromJpeg($src); break; case 3: //PNG $srcImage = imageCreateFromPng($src); break; default: return false; break; } // resampling imageCopyResampled($destImage, $srcImage, 0, 0, 0, 0,$destSize[0],$destSize[1],$srcSize[0],$srcSize[1]); // generating image switch ($srcSize[2]) { case 1: case 2: imageJpeg($destImage,$dest,$quality); break; case 3: imagePng($destImage,$dest); break; } return true; } else { return false; } } Calling code if ($photosize >= 102400 ) { $blReduce = true; } // reduce the size of a file down to 720x720 pixels at 80% quality if ($blReduce) { image_createThumb($src,$src,720,720,80); } //Create a thumbnail were the maximum width or height is 100 pixels at 100% quality // $src is the full path/filename of the large jpg file //$desc is the full path/filename of the thumbnail to be created image_createThumb($src,$dest,100,100,100); - Original Message - From: "Matt Matijevich" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Tuesday, January 20, 2004 6:24 PM Subject: Re: [PHP] thumbnail > [snip] > OK, but how? I already use GD, I need to now how to create a thumbnail, > > somebody now how to use the GD functions to create a thumbnail??? > [/snip] > > http://www.php.net/GD > > I think you want to look at: > imagecopyresampled -- Copy and resize part of an image with resampling > imagecopyresized -- Copy and resize part of an image > > or try this pear class http://pear.php.net/package/Image_Transform > like <[EMAIL PROTECTED]> suggested. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail
[snip] OK, but how? I already use GD, I need to now how to create a thumbnail, somebody now how to use the GD functions to create a thumbnail??? [/snip] http://www.php.net/GD I think you want to look at: imagecopyresampled -- Copy and resize part of an image with resampling imagecopyresized -- Copy and resize part of an image or try this pear class http://pear.php.net/package/Image_Transform like <[EMAIL PROTECTED]> suggested. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail
> [snip] > How I can create thumbnail with php? using the GD libray? > [/snip] > > yes. > > Also I hear imagemagick works well. > I included a imagemagick rotate feature into my photo gallery application as gd just cant seem to do it well ?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail
> How I can create thumbnail with php? using the GD libray? Of course u answered your own question, http://us4.php.net/manual/en/function.imagecopyresampled.php Make sure you have GD2 though you dont want crappy pixelated images. If you want a class already made up check out http://pear.php.net/package/Image_Transform i have done a custom class, which had to include a nconvert driver as there is no farhn gd on a php3 server at work. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail
[snip] How I can create thumbnail with php? using the GD libray? [/snip] yes. Also I hear imagemagick works well. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail program
On Sun, 8 Jun 2003, Artoo wrote: > thanks. I'll give that a try. Happen to know where to get sample code that > uses this program? After doing a google search for the terms mogrify php: http://www.google.com/search?q=mogrify+php The first result was this article, it appears to touch on the subject: Resizing Images with PHP and Mogrify http://www.phpbuilder.com/columns/michael20020712.php3 I'm sure there are many more examples around, and including PHP in the search field of google is very much optional. But, I guess this all depends on your knowledge of PHP... Maybe thumbnail is another good search term to throw into the mix. Regards, Philip > "Philip Olson" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > > > On Sat, 7 Jun 2003, Artoo wrote: > > > > > Anyone know of a good free thumbnail program that can be called from a > PHP > > > script using the exec() call or something similar? > > > > By far, the most popular are the tools offered by > > ImageMagick, such as mogrify: > > > > http://www.imagemagick.org/www/mogrify.html > > > > Regards, > > Philip > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail program
thanks. I'll give that a try. Happen to know where to get sample code that uses this program? "Philip Olson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > On Sat, 7 Jun 2003, Artoo wrote: > > > Anyone know of a good free thumbnail program that can be called from a PHP > > script using the exec() call or something similar? > > By far, the most popular are the tools offered by > ImageMagick, such as mogrify: > > http://www.imagemagick.org/www/mogrify.html > > Regards, > Philip > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] thumbnail program
> Anyone know of a good free thumbnail program that can be called from a PHP > script using the exec() call or something similar? Netpbm is used by Gallery. Works very well. ---John W. Holmes... Amazon Wishlist: http://www.amazon.com/o/registry/3BEXC84AB3A5E PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] thumbnail program
On Sat, 7 Jun 2003, Artoo wrote: > Anyone know of a good free thumbnail program that can be called from a PHP > script using the exec() call or something similar? By far, the most popular are the tools offered by ImageMagick, such as mogrify: http://www.imagemagick.org/www/mogrify.html Regards, Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thumbnail generation
On Mon, 23 Dec 2002, 1LT John W. Holmes wrote: > Better yet, take the time to write an Image Abstraction Layer that'll > function just like a Database Abstraction Layer. You use the same functions > no matter what and depending on the config, either GD, Imagemagik, Netpbm, > or whatever is used to do the dirty work. > > Does anyone know of such a project or want to write one? Image_Transform in PEAR: http://pear.php.net/package-info.php?pacid=83 -- Mika Tuupola http://www.appelsiini.net/~tuupola/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thumbnail generation
> i want to generate the thumbnail of an image but I want my php to be > portable. How can I generate thumbnail without depending on php host > configuration (like --with-gd) ? Along with the othe suggestions, Netpbm is something that you can package up with your application so that you are always sure it's available to it. http://netpbm.sourceforge.net/ Better yet, take the time to write an Image Abstraction Layer that'll function just like a Database Abstraction Layer. You use the same functions no matter what and depending on the config, either GD, Imagemagik, Netpbm, or whatever is used to do the dirty work. Does anyone know of such a project or want to write one? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thumbnail generation
On Monday 23 December 2002 14:26, Centaur zeus wrote: > Is there some common utilities recommended ? ImageMagick -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* It's not easy, being green. -- Kermit the Frog */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thumbnail generation
Is there some common utilities recommended ? From: Rasmus Lerdorf <[EMAIL PROTECTED]> To: Centaur zeus <[EMAIL PROTECTED]> CC: [EMAIL PROTECTED] Subject: Re: [PHP] Thumbnail generation Date: Sun, 22 Dec 2002 21:07:35 -0800 (PST) You are going to have to depend on something. If you don't want to use GD, you are going to need some external mechanism which will have to be available. -Rasmus On Mon, 23 Dec 2002, Centaur zeus wrote: > Hi all , > > i want to generate the thumbnail of an image but I want my php to be > portable. How can I generate thumbnail without depending on php host > configuration (like --with-gd) ? > > Thanks . > > Perseus > > > > _ > The new MSN 8: smart spam protection and 3 months FREE*. > http://join.msn.com/?page=features/junkmail&xAPID=42&PS=47575&PI=7324&DI=7474&SU= > http://www.hotmail.msn.com/cgi-bin/getmsg&HL=1216hotmailtaglines_smartspamprotection_3mf > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thumbnail generation
You are going to have to depend on something. If you don't want to use GD, you are going to need some external mechanism which will have to be available. -Rasmus On Mon, 23 Dec 2002, Centaur zeus wrote: > Hi all , > > i want to generate the thumbnail of an image but I want my php to be > portable. How can I generate thumbnail without depending on php host > configuration (like --with-gd) ? > > Thanks . > > Perseus > > > > _ > The new MSN 8: smart spam protection and 3 months FREE*. > http://join.msn.com/?page=features/junkmail&xAPID=42&PS=47575&PI=7324&DI=7474&SU= > >http://www.hotmail.msn.com/cgi-bin/getmsg&HL=1216hotmailtaglines_smartspamprotection_3mf > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thumbnail pages - alot of them
On Friday, June 7, 2002, at 03:06 AM, rory oconnor wrote: > I have a mysql database table of about 7000 images (they are not > actually in the db, just references), as yet uncategorized. I need to > put them online and allow my client to browse 12-18 thumbnails per page. > > what would be the most efficient method to code that with PHP? any help > is appreciated! First a disclaimer -- what I am about to tell you may sound very complicated, but only because it's hard to explain. Really, the concept is simple once you "get" it. Some people have said look into the LIMIT clause in a MySQL SELECT query. This is the right direction, but specifically you need to use the (implicit) OFFSET argument to LIMIT. Fundamentally, what you do is this: You perform a SELECT as normal, which would return all results from your database, but you use LIMIT 0, 10 which means "Limit it to 10 records starting at the first one". [Yes, it's weird since your row's primary key column probably starts with 1, but if you think about it it's not really weird, MySQL doesn't care what value is in your row's primary key column. The first record/row is 0.] The offset is going to be passed via a GET variable, so your query will look something like: SELECT row_id, row_content FROMtable WHERE where conditions here LIMIT $offset, 10; This is because if the person clicks the "next 10 rows" link, which you will provide, this link will have a querystring attached that looks something like "?offset=10" or whatever offset it is. So how do you implement this into a PHP script? Well, sure there's a lot of ways to do it but essentially, you do this: On the first page, you have two queries -- first a COUNT to see how many records are in the table, and second the above SELECT query that does the work you want done (getting the information). Now, using the first query's results (which are nothing more than the number of records in the table), you figure out how many more rows are left AFTER the offset that you are at. If this is the first page, and you are displaying ten results on the first page, then simply subtract ten from the total. If this is the second page, you have now displayed twenty records, so subtract twenty. Save this value as a variable like $rowsLeft or something. Also, you want to save the number of rows PREVIOUS to your current offset, which for the first page would be 0 but for the second page would be 10, and for the third page would be 20. Get it? This is how you will make a link that says "next 10 thumbnails" or "previous 10 thumbnails" or whatever. Next step is easy: you simply display the data however you wish to do it. I'm not going to tell you how to do this because it's the same way you'd display the data normally. Finally, you need to make the links to go backward or forward. This is the whole trick of the operation. You make a link to the page's self, but you pass along the offset so that the next query knows how to build the proper SELECT statement to return the -next- ten rows, etc. Like this: print("Next 10 Thumbnails"); Of course, the above link is really too simple. You would want to determine the number of rows that will be returned, which will usually be 10 but not always -- on the second to last page, if there are only 4 rows left to display, you don't want to say "Next 10 thumbnails" if there are only 4 left. So you need to do a simple bit of processing to get the number of rows left and print that value. Do the same for the "previous 10 thumbnails", although if you do this right you will always have a value of 10 in this section. (When would you ever end up at an offset that is not a multiple of 10?) That's all there is to it. It's complicated at first, but once you get it, you'll always be able to do it. I strongly recommend that you create a class called "ThumbnailResults" and store all of this logic in the class, since it'll keep your script cleaner. Good luck, Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Thumbnail pages - alot of them
> I have a mysql database table of about 7000 images (they are > not actually in the db, just references), as yet > uncategorized. I need to put them online and allow my > client to browse 12-18 thumbnails per page. > > what would be the most efficient method to code that with > PHP? any help is appreciated! Query your database to with an appropriate 'ORDER BY' and use 'LIMIT' to get the number you want per page. Display them to a page from within a 'while' loop. Process as you require. Include page navigation to do the next set. What have you tried? Are you having trouble with something specific? If you're not sure what to do then perhaps downloading something that will do it already will work - try www.hotscripts.com or perhaps sourceforge.net or freshmeat.net as good places to start - or even just do a search on google - I suspect searching for 'mysql php image browser' would get you close. CYA, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Thumbnail Generation from DB Stored Images.
Here is my code to turn a directory full of *files* into thumbnail images. im sure you can adapt it to your own needs... the code is a bit long-winded, but it was my first attempt at writing thumbnail code, so forgive me ;) // example call to the function make_thumbs('./pictures/cavern/', './pictures/cavern/thumbs', 200, 60 ); /* Simple function to make thumbnail images for an entire directory of .JPG images. (no GIF support because the owners of the GIF patent are buttheads) It will create square thumbnail images (height=width), with the original image resized properly within the thumbnail dimensions to preserve the height to width ratio This code is free for use as long as you keep my email and URL in here: [EMAIL PROTECTED] [EMAIL PROTECTED] http://furt.com/code/make_thumbs/ Syntax of function call make_thumbs( $dir= where the original image files are located $tdir = where you want the thumbnails to be saved $max= $max=width=height of the new thumbnail images all thumbnails are square. $quality = quality of thumbnail JPG worst(1..100)best $border = how many pixels of border to put around the image ); */ function make_thumbs($dir, $tdir, $max, $quality=75, $border=3) { // this is so the script won't time out set_time_limit(0); $files = opendir($dir) or die("Cannot opendir $dir"); while ($file = readdir($files)) { if ( preg_match("/[a-zA-Z0-9]\.(jpg|jpeg|JPG|JPEG)$/", $file) ) { //if (!file_exists($tdir .'/'. $file .'_t.jpg')) { // Information about the original image $img_name = $dir .'/'. $file; $img = imagecreatefromjpeg($img_name) or die("Cannot read $img_name"); $img_x= $img_y = 0; $img_w= imagesx($img); $img_h= imagesy($img); // Create a new empty container for the thumbnail image $out = imagecreate($max, $max); // Set background colour of the thumbnail container $bg = ImageColorAllocate($out, 200,200,200); // If image is more wide than tall if ($img_w > $img_h) { $mod = ($img_w - $max) / $img_w; $out_w = $max; $out_h = $img_h * (1 - $mod); $out_x = 0; $out_y = ($max - $out_h) / 2; $out_x += $border; $out_w -= $border*2; } // If image is more tall than wide else { $mod = ($img_h - $max) / $img_h; $out_h = $max; $out_w = $img_w * (1 - $mod); $out_y = 0; $out_x = ($max - $out_w) / 2; $out_y += $border; $out_h -= $border*2; } // for debugging purposes... so i can see what's going on //print "out_x=$out_x, out_y=$out_y, img_x=$img_x, img_y=$img_y\n"; //print "out_w=$out_w, out_h=$out_h, img_w=$img_w, img_h=$img_h\n"; //Put some text into the image //$fg = ImageColorAllocate($out, 0,0,0); //imagestring ($out, '2', 3, $max-15, "Text", $fg); // Copy and resize the original image into the new thumbnail container imagecopyresized ( $out, $img, $out_x, $out_y, $img_x, $img_y, $out_w, $out_h, $img_w, $img_h); // Save the image to disk (in the thumbnail directory) imagejpeg($out, $tdir .'/'. $file .'_t.jpg', $quality); //} }#if }#while } > -Original Message- > From: Jason Bell [mailto:[EMAIL PROTECTED]] > Sent: Thursday, July 12, 2001 7:27 PM > To: [EMAIL PROTECTED] > Subject: [PHP] Thumbnail Generation from DB Stored Images. > > > Hello! I have images stored in a MySQL Database. I can retrieve the images > and display them without a problem, but I'd really like to be able to > create thumbnails. The code that I've written just doesn't seem to work. > Preferably, I'd like to pull the image from the database, and create the > thumbnail for display, without ever writing an image to the disk. If this > is not possible, I'd like to know alternate methods. I'm using > imagemagick's convert utility to create the thumbs. Here is my code: > > getpic.php: > > if($id) { > @MYSQL_CONNECT("localhost","username","mypassword"); > @mysql_select_db("daelic"); > $query = "select image,type from images where id=$id"; > $result = @MYSQL_QUERY($query); > $data = @MYSQL_RESULT($result,0,"image"); > $type = @MYSQL_RESULT($result,0,"type"); > Header( "Content-type: $type"); >
RE: [PHP] Thumbnail Generation from DB Stored Images.
Jason-- There are many reasons I don't quite recommend creating the thumbnails on the fly with ImageMagick: 1) I've heard many say that storing/retrieving images from MySQL databases isn't the greatest idea, because you end up with -huge- tables, which leads to long query times. 2) Resizing a JPEG on the fly is a very CPU intensive task 3) Calling the shell, then calling the ImageMagick program is more and more overhead. If you insist on storing the images in the database, then you're best off storing the thumbnails in there too. If you insist on creating thumbnails on the fly, then I suggest you install PHP 4.0.6 with GD 2.0.1 and use ImageCopyResampled() or ImageCopyResized() to do it-- it'll save you from spawning a shell and running an external program. I had to create a Real Estate site, where house listings could be posted with photos to accompany them... When a photo was uploaded (HTTP upload), the script would use ImageCreateTrueColor() to create two new images, then I called ImageCopyResampled() to resize the image to two different sizes-- one thumbnail for search results, then a larger one for listing details. I stored these images in a directory in the format: /images/1_thumb.jpg /images/1_full.jpg And so on... The number (1 in this case) corresponded with the auto_increment ID of the MySQL record for the item. When the listing is deleted, PHP deletes the associated images automatically (if they exist). Good luck! -Original Message- From: Jason Bell [mailto:[EMAIL PROTECTED]] Sent: Thursday, July 12, 2001 7:27 PM To: [EMAIL PROTECTED] Subject: [PHP] Thumbnail Generation from DB Stored Images. Hello! I have images stored in a MySQL Database. I can retrieve the images and display them without a problem, but I'd really like to be able to create thumbnails. The code that I've written just doesn't seem to work. Preferably, I'd like to pull the image from the database, and create the thumbnail for display, without ever writing an image to the disk. If this is not possible, I'd like to know alternate methods. I'm using imagemagick's convert utility to create the thumbs. Here is my code: getpic.php: tgen.php: I know that getpic.php works. I can use it in like this: echo ""; and it will output the fullsize graphic in place. I'm trying to get to a point where I can use tgen.php in the same mannor. I can use the same convert command if I use an actual file, like pics/mypic.jpg and it works, so the command is good. any help at all would be very appreciated, Jason Bell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]