Oberto / php-image-magician

Image manipulation at it's finest.
http://phpimagemagician.jarrodoberto.com
91 stars 54 forks source link

Resizing question #2

Closed coverman closed 11 years ago

coverman commented 11 years ago

I just tried this script and I kinda love it. It seems very simple. But, I have a question. When a user on my site is going to upload a picture, I want it to be exactly 200x200 pixels in size.

So, the script can resize the image to follow either the height or the width and make it max 200 high or 200 wide. But, I want to have the empty area filled with a background color, like white or black.

If someone uploads an image that is 400x300, the script can resize this to something like 200x150. But I want it to add a color background to the left and right space area of the image so it ends up being a 200x200 square.

Is this possible? I tried to look at the different examples and codes, but just can't find it. Can someone help me out here?

Oberto commented 11 years ago

Hi mate,

I think what you're after is using 'exact' or 0 as the $option parameter (either 'exact' or 0 will work).

Or

Using 'crop' or 4 might do the job - depends on your needs.

Hope that helps


Extract from the code:

#             $option:     0 / exact = defined size;
#                          1 / portrait = keep aspect set height;
#                          2 / landscape = keep aspect set width;
#                          3 / auto = auto;
#                          4 / crop= resize and crop;

public function resizeImage($newWidth, $newHeight, $option = 0, $sharpen = false) { ... }

On Wed, Mar 6, 2013 at 12:00 AM, coverman notifications@github.com wrote:

I just tried this script and I kinda love it. It seems very simple. But, I have a question. When a user on my site is going to upload a picture, I want it to be exactly 200x200 pixels in size.

So, the script can resize the image to follow either the height or the width and make it max 200 high or 200 wide. But, I want to have the empty area filled with a background color, like white or black.

If someone uploads an image that is 400x300, the script can resize this to something like 200x150. But I want it to add a color background to the left and right space area of the image so it ends up being a 200x200 square.

Is this possible? I tried to look at the different examples and codes, but just can't find it. Can someone help me out here?

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/2 .

coverman commented 11 years ago

Hi there and thanx for your reply.

I tried to insert your example into one of the example files, but it didn't work the way I want.

If I upload the attached image1 which is 400x300, I want it to end up like the attached image2 file.

If I did what you suggested it stretched the image to fit the 200 x 200 and that looks a little weird.

Is there a way to make my image with your script? So the image is scaled down to either max 200 width or max 200 height.

But keeping the aspect ratio and have the image centered with a background color (in my example a white background).

Then every uploaded image in my page will have the 200x200 dimension exactly.

Don't think the crop will work, since I don't know where in the image it can be cropped from time to time.

The thing is that people will upload a photo that is supposed to be added to an area that will be exactly 200x200.

So it would be nice to help people out resizing their image in a simple way. And I guess your script can do it, but I just don't which code to use.

Staffan

On Mar 5, 2013 20:40 "Oberto" notifications@github.com wrote:

Hi mate,

I think what you're after is using 'exact' or 0 as the $option parameter (either 'exact' or 0 will work).

Or

Using 'crop' or 4 might do the job - depends on your needs.

Hope that helps



Extract from the code:

$option: 0 / exact = defined size;

1 / portrait = keep aspect set height;

2 / landscape = keep aspect set width;

3 / auto = auto;

4 / crop= resize and crop;

public function resizeImage($newWidth, $newHeight, $option = 0,

$sharpen

false) { ... }

On Wed, Mar 6, 2013 at 12:00 AM, coverman notifications@github.com wrote:

I just tried this script and I kinda love it. It seems very simple. But, I have a question. When a user on my site is going to upload a picture, I want it to be exactly 200x200 pixels in size.

So, the script can resize the image to follow either the height or the width and make it max 200 high or 200 wide. But, I want to have the empty area filled with a background color, like white or black.

If someone uploads an image that is 400x300, the script can resize this to something like 200x150. But I want it to add a color background to the left and right space area of the image so it ends up being a 200x200 square.

Is this possible? I tried to look at the different examples and codes, but just can't find it. Can someone help me out here?

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/2 .

— Reply to this email directly or view it on GitHub https://github.com/Oberto/php-image-magician/issues/2#issuecomment-14 46 0613.

Oberto commented 11 years ago

Hey again. I don't seen any attachments but just so I understand, are you asking if a user uploads an image that is smaller than the required size, then image will get padding to make it the required size?

On Wed, Mar 6, 2013 at 10:32 PM, coverman notifications@github.com wrote:

Hi there and thanx for your reply.

I tried to insert your example into one of the example files, but it didn't work the way I want.

If I upload the attached image1 which is 400x300, I want it to end up like the attached image2 file.

If I did what you suggested it stretched the image to fit the 200 x 200 and that looks a little weird.

Is there a way to make my image with your script? So the image is scaled down to either max 200 width or max 200 height.

But keeping the aspect ratio and have the image centered with a background color (in my example a white background).

Then every uploaded image in my page will have the 200x200 dimension exactly.

Don't think the crop will work, since I don't know where in the image it can be cropped from time to time.

The thing is that people will upload a photo that is supposed to be added to an area that will be exactly 200x200.

So it would be nice to help people out resizing their image in a simple way. And I guess your script can do it, but I just don't which code to use.

Staffan

On Mar 5, 2013 20:40 "Oberto" notifications@github.com wrote:

Hi mate,

I think what you're after is using 'exact' or 0 as the $option parameter (either 'exact' or 0 will work).

Or

Using 'crop' or 4 might do the job - depends on your needs.

Hope that helps



Extract from the code:

$option: 0 / exact = defined size;

1 / portrait = keep aspect set height;

2 / landscape = keep aspect set width;

3 / auto = auto;

4 / crop= resize and crop;

public function resizeImage($newWidth, $newHeight, $option = 0,

$sharpen

false) { ... }

On Wed, Mar 6, 2013 at 12:00 AM, coverman notifications@github.com wrote:

I just tried this script and I kinda love it. It seems very simple. But, I have a question. When a user on my site is going to upload a picture, I want it to be exactly 200x200 pixels in size.

So, the script can resize the image to follow either the height or the width and make it max 200 high or 200 wide. But, I want to have the empty area filled with a background color, like white or black.

If someone uploads an image that is 400x300, the script can resize this to something like 200x150. But I want it to add a color background to the left and right space area of the image so it ends up being a 200x200 square.

Is this possible? I tried to look at the different examples and codes, but just can't find it. Can someone help me out here?

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/2 .

— Reply to this email directly or view it on GitHub https://github.com/Oberto/php-image-magician/issues/2#issuecomment-14 46 0613.

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/2#issuecomment-14490130 .

coverman commented 11 years ago

Hello again.

Maybe I forgot to add the attachments, so here they are.

Actually it's when I upload an image that should be resized to something smaller.

The final image should be 200 x 200 pixels, centered in a perfect square.

If the file is 400 x 300 in original size, the script will make it 200 x 150.

That thing works fine. The image is scaled down, keeping the aspect ratio.

But, I want the script to insert space at the top and bottom, so the final image area is 200 x 200 pixels, even though the photo is only filling up the width. And the height is a photo that is 150 high, but the rest of the 25 on top and 25 at the bottom would be white space or some other color.

And if I upload a photo that is 300 x 400 instead, the it will scale it down to be a standing image, but I want it to also be 200 x 200 in the final output (but not stretched), filled with some color for the empty areas.

I hope you can see the attachments now, cause it's probably to understand what I'm trying to explain when you see the two photos.

It's actually very simple. When scaling down (not stretched), the final image should always be output as a 200 x 200 pixel photo. No matter if the original is landscape or vertical. If the image is scaled down, I want the empty areas to fill up with some color.

Staffan

On Mar 7, 2013 02:39 "Oberto" notifications@github.com wrote:

Hey again. I don't seen any attachments but just so I understand, are you asking if a user uploads an image that is smaller than the required size, then image will get padding to make it the required size?

On Wed, Mar 6, 2013 at 10:32 PM, coverman notifications@github.com wrote:

Hi there and thanx for your reply.

I tried to insert your example into one of the example files, but it didn't work the way I want.

If I upload the attached image1 which is 400x300, I want it to end up like the attached image2 file.

If I did what you suggested it stretched the image to fit the 200 x 200 and that looks a little weird.

Is there a way to make my image with your script? So the image is scaled down to either max 200 width or max 200 height.

But keeping the aspect ratio and have the image centered with a background color (in my example a white background).

Then every uploaded image in my page will have the 200x200 dimension exactly.

Don't think the crop will work, since I don't know where in the image it can be cropped from time to time.

The thing is that people will upload a photo that is supposed to be added to an area that will be exactly 200x200.

So it would be nice to help people out resizing their image in a simple way. And I guess your script can do it, but I just don't which code to use.

Staffan

On Mar 5, 2013 20:40 "Oberto" notifications@github.com wrote:

Hi mate,

I think what you're after is using 'exact' or 0 as the $option parameter (either 'exact' or 0 will work).

Or

Using 'crop' or 4 might do the job - depends on your needs.

Hope that helps



Extract from the code:

$option: 0 / exact = defined size;

1 / portrait = keep aspect set height;

2 / landscape = keep aspect set width;

3 / auto = auto;

4 / crop= resize and crop;

public function resizeImage($newWidth, $newHeight, $option = 0,

$sharpen

false) { ... }

On Wed, Mar 6, 2013 at 12:00 AM, coverman notifications@github.com wrote:

I just tried this script and I kinda love it. It seems very simple. But, I have a question. When a user on my site is going to upload a picture, I want it to be exactly 200x200 pixels in size.

So, the script can resize the image to follow either the height or the width and make it max 200 high or 200 wide. But, I want to have the empty area filled with a background color, like white or black.

If someone uploads an image that is 400x300, the script can resize this to something like 200x150. But I want it to add a color background to the left and right space area of the image so it ends up being a 200x200 square.

Is this possible? I tried to look at the different examples and codes, but just can't find it. Can someone help me out here?

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/2 .

— Reply to this email directly or view it on GitHub https://github.com/Oberto/php-image-magician/issues/2#issuecommen t- 14 46 0613.

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/2#issueco mm ent-14490130 .

— Reply to this email directly or view it on GitHub https://github.com/Oberto/php-image-magician/issues/2#issuecomment-14 53 8191.

Oberto commented 11 years ago

Weird, still can't see the attachments but I think I know what you mean now.

You could use the resize and crop - that will resize the image to the smallest length you specify, then crop the other length (from the centre although you can specify where) to make it the exact size will keeping the aspect ratio. This is most people's preferred method.

I'm not sure the script can do what you want it to do, but it might - will need to check.

Hope that helps. J.

On Thu, Mar 7, 2013 at 9:56 PM, coverman notifications@github.com wrote:

Hello again.

Maybe I forgot to add the attachments, so here they are.

Actually it's when I upload an image that should be resized to something smaller.

The final image should be 200 x 200 pixels, centered in a perfect square.

If the file is 400 x 300 in original size, the script will make it 200 x 150.

That thing works fine. The image is scaled down, keeping the aspect ratio.

But, I want the script to insert space at the top and bottom, so the final image area is 200 x 200 pixels, even though the photo is only filling up the width. And the height is a photo that is 150 high, but the rest of the 25 on top and 25 at the bottom would be white space or some other color.

And if I upload a photo that is 300 x 400 instead, the it will scale it down to be a standing image, but I want it to also be 200 x 200 in the final output (but not stretched), filled with some color for the empty areas.

I hope you can see the attachments now, cause it's probably to understand what I'm trying to explain when you see the two photos.

It's actually very simple. When scaling down (not stretched), the final image should always be output as a 200 x 200 pixel photo. No matter if the original is landscape or vertical. If the image is scaled down, I want the empty areas to fill up with some color.

Staffan

On Mar 7, 2013 02:39 "Oberto" notifications@github.com wrote:

Hey again. I don't seen any attachments but just so I understand, are you asking if a user uploads an image that is smaller than the required size, then image will get padding to make it the required size?

On Wed, Mar 6, 2013 at 10:32 PM, coverman notifications@github.com wrote:

Hi there and thanx for your reply.

I tried to insert your example into one of the example files, but it didn't work the way I want.

If I upload the attached image1 which is 400x300, I want it to end up like the attached image2 file.

If I did what you suggested it stretched the image to fit the 200 x 200 and that looks a little weird.

Is there a way to make my image with your script? So the image is scaled down to either max 200 width or max 200 height.

But keeping the aspect ratio and have the image centered with a background color (in my example a white background).

Then every uploaded image in my page will have the 200x200 dimension exactly.

Don't think the crop will work, since I don't know where in the image it can be cropped from time to time.

The thing is that people will upload a photo that is supposed to be added to an area that will be exactly 200x200.

So it would be nice to help people out resizing their image in a simple way. And I guess your script can do it, but I just don't which code to use.

Staffan

On Mar 5, 2013 20:40 "Oberto" notifications@github.com wrote:

Hi mate,

I think what you're after is using 'exact' or 0 as the $option parameter (either 'exact' or 0 will work).

Or

Using 'crop' or 4 might do the job - depends on your needs.

Hope that helps



Extract from the code:

$option: 0 / exact = defined size;

1 / portrait = keep aspect set height;

2 / landscape = keep aspect set width;

3 / auto = auto;

4 / crop= resize and crop;

public function resizeImage($newWidth, $newHeight, $option = 0,

$sharpen

false) { ... }

On Wed, Mar 6, 2013 at 12:00 AM, coverman notifications@github.com wrote:

I just tried this script and I kinda love it. It seems very simple. But, I have a question. When a user on my site is going to upload a picture, I want it to be exactly 200x200 pixels in size.

So, the script can resize the image to follow either the height or the width and make it max 200 high or 200 wide. But, I want to have the empty area filled with a background color, like white or black.

If someone uploads an image that is 400x300, the script can resize this to something like 200x150. But I want it to add a color background to the left and right space area of the image so it ends up being a 200x200 square.

Is this possible? I tried to look at the different examples and codes, but just can't find it. Can someone help me out here?

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/2 .

— Reply to this email directly or view it on GitHub https://github.com/Oberto/php-image-magician/issues/2#issuecommen t- 14 46 0613.

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/2#issueco mm ent-14490130 .

— Reply to this email directly or view it on GitHub https://github.com/Oberto/php-image-magician/issues/2#issuecomment-14 53 8191.

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/2#issuecomment-14549056 .

Oberto commented 11 years ago

Also, out of curiosity, how did you find out about PHP Image Magician?

On Fri, Mar 8, 2013 at 9:02 AM, Jarrod Oberto jarrod@oberto.co.nz wrote:

Weird, still can't see the attachments but I think I know what you mean now.

You could use the resize and crop - that will resize the image to the smallest length you specify, then crop the other length (from the centre although you can specify where) to make it the exact size will keeping the aspect ratio. This is most people's preferred method.

I'm not sure the script can do what you want it to do, but it might - will need to check.

Hope that helps. J.

On Thu, Mar 7, 2013 at 9:56 PM, coverman notifications@github.com wrote:

Hello again.

Maybe I forgot to add the attachments, so here they are.

Actually it's when I upload an image that should be resized to something smaller.

The final image should be 200 x 200 pixels, centered in a perfect square.

If the file is 400 x 300 in original size, the script will make it 200 x 150.

That thing works fine. The image is scaled down, keeping the aspect ratio.

But, I want the script to insert space at the top and bottom, so the final image area is 200 x 200 pixels, even though the photo is only filling up the width. And the height is a photo that is 150 high, but the rest of the 25 on top and 25 at the bottom would be white space or some other color.

And if I upload a photo that is 300 x 400 instead, the it will scale it down to be a standing image, but I want it to also be 200 x 200 in the final output (but not stretched), filled with some color for the empty areas.

I hope you can see the attachments now, cause it's probably to understand what I'm trying to explain when you see the two photos.

It's actually very simple. When scaling down (not stretched), the final image should always be output as a 200 x 200 pixel photo. No matter if the original is landscape or vertical. If the image is scaled down, I want the empty areas to fill up with some color.

Staffan

On Mar 7, 2013 02:39 "Oberto" notifications@github.com wrote:

Hey again. I don't seen any attachments but just so I understand, are you asking if a user uploads an image that is smaller than the required size, then image will get padding to make it the required size?

On Wed, Mar 6, 2013 at 10:32 PM, coverman notifications@github.com wrote:

Hi there and thanx for your reply.

I tried to insert your example into one of the example files, but it didn't work the way I want.

If I upload the attached image1 which is 400x300, I want it to end up like the attached image2 file.

If I did what you suggested it stretched the image to fit the 200 x 200 and that looks a little weird.

Is there a way to make my image with your script? So the image is scaled down to either max 200 width or max 200 height.

But keeping the aspect ratio and have the image centered with a background color (in my example a white background).

Then every uploaded image in my page will have the 200x200 dimension exactly.

Don't think the crop will work, since I don't know where in the image it can be cropped from time to time.

The thing is that people will upload a photo that is supposed to be added to an area that will be exactly 200x200.

So it would be nice to help people out resizing their image in a simple way. And I guess your script can do it, but I just don't which code to use.

Staffan

On Mar 5, 2013 20:40 "Oberto" notifications@github.com wrote:

Hi mate,

I think what you're after is using 'exact' or 0 as the $option parameter (either 'exact' or 0 will work).

Or

Using 'crop' or 4 might do the job - depends on your needs.

Hope that helps



Extract from the code:

$option: 0 / exact = defined size;

1 / portrait = keep aspect set height;

2 / landscape = keep aspect set width;

3 / auto = auto;

4 / crop= resize and crop;

public function resizeImage($newWidth, $newHeight, $option = 0,

$sharpen

false) { ... }

On Wed, Mar 6, 2013 at 12:00 AM, coverman notifications@github.com wrote:

I just tried this script and I kinda love it. It seems very simple. But, I have a question. When a user on my site is going to upload a picture, I want it to be exactly 200x200 pixels in size.

So, the script can resize the image to follow either the height or the width and make it max 200 high or 200 wide. But, I want to have the empty area filled with a background color, like white or black.

If someone uploads an image that is 400x300, the script can resize this to something like 200x150. But I want it to add a color background to the left and right space area of the image so it ends up being a 200x200 square.

Is this possible? I tried to look at the different examples and codes, but just can't find it. Can someone help me out here?

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/2 .

— Reply to this email directly or view it on GitHub https://github.com/Oberto/php-image-magician/issues/2#issuecommen t- 14 46 0613.

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/2#issueco mm ent-14490130 .

— Reply to this email directly or view it on GitHub https://github.com/Oberto/php-image-magician/issues/2#issuecomment-14 53 8191.

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/2#issuecomment-14549056 .

coverman commented 11 years ago

Not sure, but I was searching around. Probably a tip from someone in a forum I guess.

On Mar 7, 2013 21:03 "Oberto" notifications@github.com wrote:

Also, out of curiosity, how did you find out about PHP Image Magician?

On Fri, Mar 8, 2013 at 9:02 AM, Jarrod Oberto jarrod@oberto.co.nz wrote:

Weird, still can't see the attachments but I think I know what you mean now.

You could use the resize and crop - that will resize the image to the smallest length you specify, then crop the other length (from the centre although you can specify where) to make it the exact size will keeping the aspect ratio. This is most people's preferred method.

I'm not sure the script can do what you want it to do, but it might

will need to check.

Hope that helps. J.

On Thu, Mar 7, 2013 at 9:56 PM, coverman notifications@github.com wrote:

Hello again.

Maybe I forgot to add the attachments, so here they are.

Actually it's when I upload an image that should be resized to something smaller.

The final image should be 200 x 200 pixels, centered in a perfect square.

If the file is 400 x 300 in original size, the script will make it 200 x 150.

That thing works fine. The image is scaled down, keeping the aspect ratio.

But, I want the script to insert space at the top and bottom, so the final image area is 200 x 200 pixels, even though the photo is only filling up the width. And the height is a photo that is 150 high, but the rest of the 25 on top and 25 at the bottom would be white space or some other color.

And if I upload a photo that is 300 x 400 instead, the it will scale it down to be a standing image, but I want it to also be 200 x 200 in the final output (but not stretched), filled with some color for the empty areas.

I hope you can see the attachments now, cause it's probably to understand what I'm trying to explain when you see the two photos.

It's actually very simple. When scaling down (not stretched), the final image should always be output as a 200 x 200 pixel photo. No matter if the original is landscape or vertical. If the image is scaled down, I want the empty areas to fill up with some color.

Staffan

On Mar 7, 2013 02:39 "Oberto" notifications@github.com wrote:

Hey again. I don't seen any attachments but just so I understand, are you asking if a user uploads an image that is smaller than the required size, then image will get padding to make it the required size?

On Wed, Mar 6, 2013 at 10:32 PM, coverman notifications@github.com wrote:

Hi there and thanx for your reply.

I tried to insert your example into one of the example files, but it didn't work the way I want.

If I upload the attached image1 which is 400x300, I want it to end up like the attached image2 file.

If I did what you suggested it stretched the image to fit the 200 x 200 and that looks a little weird.

Is there a way to make my image with your script? So the image is scaled down to either max 200 width or max 200 height.

But keeping the aspect ratio and have the image centered with a background color (in my example a white background).

Then every uploaded image in my page will have the 200x200 dimension exactly.

Don't think the crop will work, since I don't know where in the image it can be cropped from time to time.

The thing is that people will upload a photo that is supposed to be added to an area that will be exactly 200x200.

So it would be nice to help people out resizing their image in a simple way. And I guess your script can do it, but I just don't which code to use.

Staffan

On Mar 5, 2013 20:40 "Oberto" notifications@github.com wrote:

Hi mate,

I think what you're after is using 'exact' or 0 as the $option parameter (either 'exact' or 0 will work).

Or

Using 'crop' or 4 might do the job - depends on your needs.

Hope that helps




Extract from the code:

$option: 0 / exact = defined size;

1 / portrait = keep aspect set height;

2 / landscape = keep aspect set width;

3 / auto = auto;

4 / crop= resize and crop;

public function resizeImage($newWidth, $newHeight, $option = 0,

$sharpen

false) { ... }

On Wed, Mar 6, 2013 at 12:00 AM, coverman notifications@github.com wrote:

I just tried this script and I kinda love it. It seems very simple. But, I have a question. When a user on my site is going to upload a picture, I want it to be exactly 200x200 pixels in size.

So, the script can resize the image to follow either the height or the width and make it max 200 high or 200 wide. But, I want to have the empty area filled with a background color, like white or black.

If someone uploads an image that is 400x300, the script can resize this to something like 200x150. But I want it to add a color background to the left and right space area of the image so it ends up being a 200x200 square.

Is this possible? I tried to look at the different examples and codes, but just can't find it. Can someone help me out here?

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/ 2 .

— Reply to this email directly or view it on GitHub https://github.com/Oberto/php-image-magician/issues/2#issuec om men t- 14 46 0613.

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/2#is su eco mm ent-14490130 .

— Reply to this email directly or view it on GitHub https://github.com/Oberto/php-image-magician/issues/2#issuecomme nt -14 53 8191.

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/2#issuec om ment-14549056 .

— Reply to this email directly or view it on GitHub https://github.com/Oberto/php-image-magician/issues/2#issuecomment-14 58 2823.

coverman commented 11 years ago

Hello again.

Since you couldn't see my attached images, I have now uploaded three images on a page.

Maybe you can understand what I'm looking for when you see that.

I want the uploaded image to be resized to max 200 x 200. And if it's to low or to narrow, then the unused space should be filled with white color. If the uploaded image is smaller than 200 x 200, then it would just be centered and with a white background surrounding the image to fill the space.

Here is my example:

http://coverman.se/testing.html

Now, when writing this e-mail I thought about your watermark function.

Is it possible to make a white image and then have the new image uploaded as a watermark, centered onto the first image?

Or is there another better solution to make my wish come true?

Staffan

On Mar 7, 2013 21:03 "Oberto" notifications@github.com wrote:

Also, out of curiosity, how did you find out about PHP Image Magician?

On Fri, Mar 8, 2013 at 9:02 AM, Jarrod Oberto jarrod@oberto.co.nz wrote:

Weird, still can't see the attachments but I think I know what you mean now.

You could use the resize and crop - that will resize the image to the smallest length you specify, then crop the other length (from the centre although you can specify where) to make it the exact size will keeping the aspect ratio. This is most people's preferred method.

I'm not sure the script can do what you want it to do, but it might

will need to check.

Hope that helps. J.

On Thu, Mar 7, 2013 at 9:56 PM, coverman notifications@github.com wrote:

Hello again.

Maybe I forgot to add the attachments, so here they are.

Actually it's when I upload an image that should be resized to something smaller.

The final image should be 200 x 200 pixels, centered in a perfect square.

If the file is 400 x 300 in original size, the script will make it 200 x 150.

That thing works fine. The image is scaled down, keeping the aspect ratio.

But, I want the script to insert space at the top and bottom, so the final image area is 200 x 200 pixels, even though the photo is only filling up the width. And the height is a photo that is 150 high, but the rest of the 25 on top and 25 at the bottom would be white space or some other color.

And if I upload a photo that is 300 x 400 instead, the it will scale it down to be a standing image, but I want it to also be 200 x 200 in the final output (but not stretched), filled with some color for the empty areas.

I hope you can see the attachments now, cause it's probably to understand what I'm trying to explain when you see the two photos.

It's actually very simple. When scaling down (not stretched), the final image should always be output as a 200 x 200 pixel photo. No matter if the original is landscape or vertical. If the image is scaled down, I want the empty areas to fill up with some color.

Staffan

On Mar 7, 2013 02:39 "Oberto" notifications@github.com wrote:

Hey again. I don't seen any attachments but just so I understand, are you asking if a user uploads an image that is smaller than the required size, then image will get padding to make it the required size?

On Wed, Mar 6, 2013 at 10:32 PM, coverman notifications@github.com wrote:

Hi there and thanx for your reply.

I tried to insert your example into one of the example files, but it didn't work the way I want.

If I upload the attached image1 which is 400x300, I want it to end up like the attached image2 file.

If I did what you suggested it stretched the image to fit the 200 x 200 and that looks a little weird.

Is there a way to make my image with your script? So the image is scaled down to either max 200 width or max 200 height.

But keeping the aspect ratio and have the image centered with a background color (in my example a white background).

Then every uploaded image in my page will have the 200x200 dimension exactly.

Don't think the crop will work, since I don't know where in the image it can be cropped from time to time.

The thing is that people will upload a photo that is supposed to be added to an area that will be exactly 200x200.

So it would be nice to help people out resizing their image in a simple way. And I guess your script can do it, but I just don't which code to use.

Staffan

On Mar 5, 2013 20:40 "Oberto" notifications@github.com wrote:

Hi mate,

I think what you're after is using 'exact' or 0 as the $option parameter (either 'exact' or 0 will work).

Or

Using 'crop' or 4 might do the job - depends on your needs.

Hope that helps




Extract from the code:

$option: 0 / exact = defined size;

1 / portrait = keep aspect set height;

2 / landscape = keep aspect set width;

3 / auto = auto;

4 / crop= resize and crop;

public function resizeImage($newWidth, $newHeight, $option = 0,

$sharpen

false) { ... }

On Wed, Mar 6, 2013 at 12:00 AM, coverman notifications@github.com wrote:

I just tried this script and I kinda love it. It seems very simple. But, I have a question. When a user on my site is going to upload a picture, I want it to be exactly 200x200 pixels in size.

So, the script can resize the image to follow either the height or the width and make it max 200 high or 200 wide. But, I want to have the empty area filled with a background color, like white or black.

If someone uploads an image that is 400x300, the script can resize this to something like 200x150. But I want it to add a color background to the left and right space area of the image so it ends up being a 200x200 square.

Is this possible? I tried to look at the different examples and codes, but just can't find it. Can someone help me out here?

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/ 2 .

— Reply to this email directly or view it on GitHub https://github.com/Oberto/php-image-magician/issues/2#issuec om men t- 14 46 0613.

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/2#is su eco mm ent-14490130 .

— Reply to this email directly or view it on GitHub https://github.com/Oberto/php-image-magician/issues/2#issuecomme nt -14 53 8191.

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/2#issuec om ment-14549056 .

— Reply to this email directly or view it on GitHub https://github.com/Oberto/php-image-magician/issues/2#issuecomment-14 58 2823.

Oberto commented 11 years ago

Hmm... I'll have a look. I know I had that functionality in my dev build but haven't had the time to fully test it.

On Tue, Mar 19, 2013 at 12:12 AM, coverman notifications@github.com wrote:

Hello again.

Since you couldn't see my attached images, I have now uploaded three images on a page.

Maybe you can understand what I'm looking for when you see that.

I want the uploaded image to be resized to max 200 x 200. And if it's to low or to narrow, then the unused space should be filled with white color. If the uploaded image is smaller than 200 x 200, then it would just be centered and with a white background surrounding the image to fill the space.

Here is my example:

http://coverman.se/testing.html

Now, when writing this e-mail I thought about your watermark function.

Is it possible to make a white image and then have the new image uploaded as a watermark, centered onto the first image?

Or is there another better solution to make my wish come true?

Staffan

On Mar 7, 2013 21:03 "Oberto" notifications@github.com wrote:

Also, out of curiosity, how did you find out about PHP Image Magician?

On Fri, Mar 8, 2013 at 9:02 AM, Jarrod Oberto jarrod@oberto.co.nz wrote:

Weird, still can't see the attachments but I think I know what you mean now.

You could use the resize and crop - that will resize the image to the smallest length you specify, then crop the other length (from the centre although you can specify where) to make it the exact size will keeping the aspect ratio. This is most people's preferred method.

I'm not sure the script can do what you want it to do, but it might

will need to check.

Hope that helps. J.

On Thu, Mar 7, 2013 at 9:56 PM, coverman notifications@github.com wrote:

Hello again.

Maybe I forgot to add the attachments, so here they are.

Actually it's when I upload an image that should be resized to something smaller.

The final image should be 200 x 200 pixels, centered in a perfect square.

If the file is 400 x 300 in original size, the script will make it 200 x 150.

That thing works fine. The image is scaled down, keeping the aspect ratio.

But, I want the script to insert space at the top and bottom, so the final image area is 200 x 200 pixels, even though the photo is only filling up the width. And the height is a photo that is 150 high, but the rest of the 25 on top and 25 at the bottom would be white space or some other color.

And if I upload a photo that is 300 x 400 instead, the it will scale it down to be a standing image, but I want it to also be 200 x 200 in the final output (but not stretched), filled with some color for the empty areas.

I hope you can see the attachments now, cause it's probably to understand what I'm trying to explain when you see the two photos.

It's actually very simple. When scaling down (not stretched), the final image should always be output as a 200 x 200 pixel photo. No matter if the original is landscape or vertical. If the image is scaled down, I want the empty areas to fill up with some color.

Staffan

On Mar 7, 2013 02:39 "Oberto" notifications@github.com wrote:

Hey again. I don't seen any attachments but just so I understand, are you asking if a user uploads an image that is smaller than the required size, then image will get padding to make it the required size?

On Wed, Mar 6, 2013 at 10:32 PM, coverman notifications@github.com wrote:

Hi there and thanx for your reply.

I tried to insert your example into one of the example files, but it didn't work the way I want.

If I upload the attached image1 which is 400x300, I want it to end up like the attached image2 file.

If I did what you suggested it stretched the image to fit the 200 x 200 and that looks a little weird.

Is there a way to make my image with your script? So the image is scaled down to either max 200 width or max 200 height.

But keeping the aspect ratio and have the image centered with a background color (in my example a white background).

Then every uploaded image in my page will have the 200x200 dimension exactly.

Don't think the crop will work, since I don't know where in the image it can be cropped from time to time.

The thing is that people will upload a photo that is supposed to be added to an area that will be exactly 200x200.

So it would be nice to help people out resizing their image in a simple way. And I guess your script can do it, but I just don't which code to use.

Staffan

On Mar 5, 2013 20:40 "Oberto" notifications@github.com wrote:

Hi mate,

I think what you're after is using 'exact' or 0 as the $option parameter (either 'exact' or 0 will work).

Or

Using 'crop' or 4 might do the job - depends on your needs.

Hope that helps




Extract from the code:

$option: 0 / exact = defined size;

1 / portrait = keep aspect set height;

2 / landscape = keep aspect set width;

3 / auto = auto;

4 / crop= resize and crop;

public function resizeImage($newWidth, $newHeight, $option = 0,

$sharpen

false) { ... }

On Wed, Mar 6, 2013 at 12:00 AM, coverman notifications@github.com wrote:

I just tried this script and I kinda love it. It seems very simple. But, I have a question. When a user on my site is going to upload a picture, I want it to be exactly 200x200 pixels in size.

So, the script can resize the image to follow either the height or the width and make it max 200 high or 200 wide. But, I want to have the empty area filled with a background color, like white or black.

If someone uploads an image that is 400x300, the script can resize this to something like 200x150. But I want it to add a color background to the left and right space area of the image so it ends up being a 200x200 square.

Is this possible? I tried to look at the different examples and codes, but just can't find it. Can someone help me out here?

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/ 2 .

— Reply to this email directly or view it on GitHub https://github.com/Oberto/php-image-magician/issues/2#issuec om men t- 14 46 0613.

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/2#is su eco mm ent-14490130 .

— Reply to this email directly or view it on GitHub https://github.com/Oberto/php-image-magician/issues/2#issuecomme nt -14 53 8191.

— Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/2#issuec om ment-14549056 .

— Reply to this email directly or view it on GitHub https://github.com/Oberto/php-image-magician/issues/2#issuecomment-14 58 2823.

—

Reply to this email directly or view it on GitHubhttps://github.com/Oberto/php-image-magician/issues/2#issuecomment-15049398 .