Jump to content

Loading Image crop


ptolomea

Recommended Posts

Hey, I'm looking to crop an image when its being loaded into the website, I'm not concerned with loading time as most likely it will be a forked script anyways.

 

All the scripts and functions that I have researched and looked into require you to specify a destination image, I would like to use the source image and crop the output for just the loading page and would like to avoid having 2 images one full and one cropped since both images will be used, and space will be a big issue which is why I'm trying to avoid a 2nd image.

 

Now since I don't have code to trouble-shoot I'm not looking for code to be placed here, what I would like is a point to the right direction that way should I need it I can reply with code to trouble-shoot.

 

Thanks.

Link to comment
Share on other sites

GD library can do almost anything to an image (or make its own if you don't like the current one), however you can't exactly crop an upload file without sending it to a destination (it be pretty pointless), also it be better to use a temp storage if you want to have previewing of the cropped image.  As for defining the image, it can be defined by the uploader, time, date, random, etc.

Link to comment
Share on other sites

any image that will be on the website will not be uploaded by a user it will all be put on the server by hand and then modified in any way

 

a good way to think of what I would like to do is picture a book cover if you lay it flat you have the back cover the spine then the front cover.  Now I'd like to only show the front cover on the main page and then the entire thing if it is clicked on.

Link to comment
Share on other sites

well it can't really crop that easily based on what the image is (it can but its amazingly hard) but you could crop it to a certain amount of pixels.  But basically I'd suggest looking into the glob function and after you upload all the images resize them using a

<?php
$files = glob($imgfolder);
Foreach($files as $value);
{
//Resize here
}
?>

 

And then if you wanted to add some logic to it saying if its already resized dont' resize

Link to comment
Share on other sites

When you say crop that implies taking off part of an image, not resizing the whole image.  Which isn't a strong point in gd for the reason that it can't read a whole image really well (For the user that is), if you wanted to crop at a specific point like on a line, it would have to find that line with a pixel by pixel anyalsis then crop along that line for example, however if all images are the same size and the crop point is at points (x1,y1 to x2,y2) then its no challenge at all.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.