L
L
Leonid2016-08-22 10:50:34
PHP
Leonid, 2016-08-22 10:50:34

Crop an image to the bounds of an internal object in PHP - is it possible?

The site displays logos in the form:
d175e77ac2.png
logos can have different widths, but must always have the same height.
Since the logos on the images can be of different shapes and sizes, i.e. with a lot of background around or vice versa, the logo takes up most of the image, then you have to constantly run the logo through some kind of Photoshop, cropping the logo itself on the image to the desired size.
Is it possible to make automatic cropping in PHP for such a task? In images, logos are always on a white (solid color) or transparent background.
As a last resort, it would be possible to provide the user with the ability to independently crop directly on the page via JavaScript - tell me such tools so as not to invent a wheel?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
iBird Rose, 2016-08-22
@iiiBird

I mean, what's the problem? wrap images in div. specify images max-height: 100%; and actually everything. upload any pictures you want. they will be normal. to avoid two images sticking together - specify padding for the div in which the img is wrapped

X
xmoonlight, 2016-08-22
@xmoonlight

PHP has a built-in GD2 graphics library for working with images.
With it, you can define the boundaries of the image and then cut it out as needed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question