Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Foolio882
Jun 16, 2003

by Fistgrrl
Dear god somebody please help!

php:
<?php
echo "test";
$im createfromjpeg('../images/test.jpg');

if (!$im) 
{
    die ('Unable to open image');
}

echo "Image Opened";
?>
Outputs...

test
Fatal error:Call to undefined function createfromjpeg() at line whatever


GD Version 2.0.34 is installed, with jpeg support.

Anyone have any ideas? Once I get this poo poo worked out I can actually start this project :mad:

Adbot
ADBOT LOVES YOU

Foolio882
Jun 16, 2003

by Fistgrrl
Hey, whatdya know, I'm an idiot.

Thanks! :downs:

Foolio882
Jun 16, 2003

by Fistgrrl
I'm back, this time header() is giving me hell()

php:
<?php header('Content-type: image/jpeg');?>
<html>
<body>
<?php
//functions.inc contains displayPictureTable()
include("functions.inc");
//displayPictureTable works correctly up until picture output
displayPictureTable(shedsgable);
?>
</body>
</html>
Hopefully this one is as simple as the last time, but I just cannot figure out why this won't work.

My function displayPictureTable() works as it should as this all currently sits. It outputs my two test echos, and then attempts to output the picture I have designated but instead of pretty colors, I only get gibberish:

code:
CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality ÿÛC    
$.' ",#(7),01444'9=82<.342ÿÛC  2!!22222222222222222222222222222222222222222222222222ÿÀ– ...and on and on and on
Here are the steps I have gone through:

1) No header(), gibberish.
2) Put header() in the wrong spot, error message and gibberish
3) [Where I am now] I have header() in what I believed to be the correct location, am getting no error messages (E_ALL), but I'm still not getting a picture.

I'm certain this is another stupid mistake (hopefully) common amongst those of us new to php, but I just can't pinpoint what the hell is going wrong here :(

Foolio882
Jun 16, 2003

by Fistgrrl

duz posted:

You can't send headers after outputting content.

True, but getting rid of my "html nonsense" changes nothing as well:

php:
<?php header('Content-type: image/jpeg');
 
include("functions.inc");
 
displayPictureTable(shedsgable);
 
?>

Foolio882
Jun 16, 2003

by Fistgrrl

fletcher posted:

What exactly does displayPictureTable spit out? You can't output any text or html with that header set.

Oh dear god I think I'm hosed, as the function name suggests, this is supposed to be outputting a picture table and it's loaded with required html.

Is there any way to mix html and php to output a table of pictures? I'd like to avoid iterating through the directory to display them as html pictures, as I need the displayed pictures to be thumbnail links to fullsize pictures.

Something like this would work, but be a complete and total pain in the rear end:

php:
<?
$directory = opendir($picPath);

while($fileName = readdir($directory)) {
    $dirArray[] = $fileName;
}

//Here display $picPath/thumbs/$dirArray[1,2,...n] as links to $picPath/$dirArray[1,2,...n]
?>
You see my anger, I'd then have to make sure all the file names were identical and have to create a thumbnail every time we want to add a picture to the table as opposed to just uploading it at the correct resolution into one folder and dynamically resizing it.

This is going to suck.

Foolio882
Jun 16, 2003

by Fistgrrl

fletcher posted:


If you want thumbnails created automatically, when you read the directory of pictures also look or the <filename>_thumbnail.jpg, if it's not there, then create it, save it, and move on. You can use GD (built into PHP) to resize the images. I'm still kinda confused on what you are trying to do though.

But that's what I am trying to avoid, having seperate thumbnails.

Here's the ultimate goal:

1) A potential customer comes to our website, and is interested in a Shed, Deck, or Gazebo, and would like to see some of our recent projects.

2) They somehow navigate to the "Sheds" section of recent projects, and want to see, for example, Gable style sheds that we have built.

3) Some time before this, someone has put a whole bunch of pictures into ./images/sheds/gable

4) On recentprojects/sheds/gable.php (Or whatever it may be, I don't care) this potential customer will see a table (looks aside, that's not my job) of thumbnails for every picture in ./images/sheds/gable/

5) Each thumbnail is a link to a full size picture opening in a new window.

6) And then we somehow get another building to stand upright (Call it a gazebo), photograph it, throw it into ./images/gazebos and it's a new addition to recentprojects/gazebos.php (Just sitting there pretty at the end of the line, nothing fancy)

I can do this all day long (and in fact did, as proof of concept) with seperate directories for thumbs and full size images, but thats just not the way I'd like to go if at all possible.

edit: I just re-read your post. Are you suggesting the code do these steps:?

1) Get list of filenames in, for example, ./images/decks
2) Check if $dirArray[0] exists in ./images/decks, output with html if YES
3) If NO, create thumbnail, save. Output with html.
4) repeat.

That makes sense to me, but I'm not sure how to use gd to actually create a new *.jpg int he event of a missing thumbnail.

Foolio882 fucked around with this message at 21:54 on Mar 31, 2008

Foolio882
Jun 16, 2003

by Fistgrrl

fletcher posted:

You can use width and height on the <img> tag (which is a horrible way to do it) otherwise you are going to have to create separate thumbnails. Why is that such a bad solution if it's done automatically?

If it can be done automatically, I'm all for it and that will work just fine and dandy. I just did a bit of quick googling and found some very relevant information, and hopefully this will all come together nicely.
(Read: I'll be back later with more awful questions, but you all have been very helpful and I do appreciate it!)

Adbot
ADBOT LOVES YOU

Foolio882
Jun 16, 2003

by Fistgrrl

admiraldennis posted:

Yeah, this is all pretty basic knowledge stuff.

Did you read/comprehend my post?

What can I say, I'm new to this stuff :v:

And yes, it all made sense to me, mostly. Would using GET and that makeThumb.php script you suggested work just as well for the one time "Oops, we don't have a thumbnail!" moments?

The one part of your post I didn't fully comprehend was "a simple 404 redirection could point to a thumbnail generation script that would fetch the original image ('/img/pic1.jpg'), return the resized one to the browser, and then store the resized one in the thumbs for later use. " I understand the goal there, and think it would work very well, but can you clarify what I've bolded? Is that what you already talked about with the makeThumb.php script?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply