Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Image Cropping in PHP
Old 05-23-2011, 12:48 PM Image Cropping in PHP
asmalik12's Avatar
Extreme Talker

Posts: 173
Name: Abdullah Saleem
Trades: 0
Hi,

I wanna use Image crop function in PHP. Image source is

PHP Code:
<?php echo get_post_meta($post->ID"Image"true); ?>
for the size width: 315px; height: 245px;

using this

PHP Code:
<?php
// Create image instances
$src imagecreatefromgif('php.gif');
$dest imagecreatetruecolor(8040);

// Copy
imagecopy($dest$src0020138040);

// Output and free from memory
header('Content-Type: image/gif');
imagegif($dest);

imagedestroy($dest);
imagedestroy($src);
?>
I'm just confused with the image source here !
__________________
"Think 100 times before you take a decision, But once that decision is taken, stand by it as one man." - Quaid-e-Azam

Last edited by asmalik12; 05-23-2011 at 12:49 PM..
asmalik12 is offline
Reply With Quote
View Public Profile Visit asmalik12's homepage!
 
 
Register now for full access!
Old 05-23-2011, 12:51 PM Re: Image Cropping in PHP
Super Spam Talker

Posts: 880
Name: Paul W
Trades: 0
And the question is?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is online now
Reply With Quote
View Public Profile
 
Old 05-23-2011, 02:43 PM Re: Image Cropping in PHP
asmalik12's Avatar
Extreme Talker

Posts: 173
Name: Abdullah Saleem
Trades: 0
Sorry, I didn't post a proper question, then.

I want to use Image crop script using the image source as

PHP Code:
<?php echo get_post_meta($post->ID"Image"true); ?>
I just want to know should php tags come in the following code or just without them like this:

PHP Code:
echo get_post_meta($post->ID"Image"true); 
for the following code:

PHP Code:
<?php 
// Create image instances 
$src imagecreatefromgif('<?php echo get_post_meta($post->ID, "Image", true); ?>'); 
$dest imagecreatetruecolor(8040); 

// Copy 
imagecopy($dest$src0020138040); 

// Output and free from memory 
header('Content-Type: image/gif'); 
imagegif($dest); 

imagedestroy($dest); 
imagedestroy($src); 
?>
__________________
"Think 100 times before you take a decision, But once that decision is taken, stand by it as one man." - Quaid-e-Azam

Last edited by asmalik12; 05-23-2011 at 11:57 PM..
asmalik12 is offline
Reply With Quote
View Public Profile Visit asmalik12's homepage!
 
Old 05-25-2011, 07:03 PM Re: Image Cropping in PHP
Super Spam Talker

Posts: 880
Name: Paul W
Trades: 0
It depends - if that line is inside <?php already, then no.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is online now
Reply With Quote
View Public Profile
 
Old 05-26-2011, 04:30 AM Re: Image Cropping in PHP
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
You still haven't given us much to go on, so I'm just gonna take a big guess here.

I think get_post_meta() is a function that fetches some image data, perhaps from a database, and returns the data with an image header. That is, if you just open the page that calls that function in a browser, it would actually show an image.

Now, the function imagecreatefromgif() want's an image source, a path to an image file. So you should simply give it the path to the file that calls the get_post_meta() function, as in
PHP Code:
$src imagecreatefromgif("path/to/file.php"); 
If that doesn't work, I doubt we'll be able to help you unless you are more specific. You could for example show us some code of what the get_post_meta() function actually does, since you don't seem to know yourself.
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 05-26-2011, 04:36 AM Re: Image Cropping in PHP
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
This line:
PHP Code:
$src = imagecreatefromgif('<?php echo get_post_meta($post->ID"Image"true); ?>');
Should just be:

PHP Code:
$src imagecreatefromgifget_post_meta($post->ID"Image"true) ); 
You are passing the output of get_post_meta to the imagecreatefromgif function. You should already be in PHP mode when you call this function, and even if you weren't, putting php tags in the middle of a string would not have the desired effect.

Quote:
Originally Posted by lizciz View Post
You could for example show us some code of what the get_post_meta() function actually does, since you don't seem to know yourself.
get_post_meta is a function built into wordpress. It retrieves a meta data for a given post.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 05-26-2011 at 04:38 AM..
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 05-26-2011, 11:02 AM Re: Image Cropping in PHP
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Quote:
Originally Posted by NullPointer View Post
get_post_meta is a function built into wordpress. It retrieves a meta data for a given post.
Aha, I didn't know that
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Reply     « Reply to Image Cropping in PHP
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.38932 seconds with 12 queries