0
\$\begingroup\$

I have a set of images, all of which have quite different resolutions from each other. I want to first crop them in the ratio 2:1 and then resize them to 1000x500 so that the image is not stretched or distorted in any way. I used different image resizer programs to do it but I am able to process only a few images at a time whose lengths are approximately equal. I want a software or a piece of PHP or Java code to process all of the images at once and crop them all in the ratio 2:1 in the center. Any help would be greatly appreciated as I need this often.

\$\endgroup\$
6
  • 3
    \$\begingroup\$ Just to confirm: if you had a 4000x4000 image, you would want to first crop it to 4000x2000 (how do you choose where to crop - centre of the image?) and then resize that to 1000x500? \$\endgroup\$
    – Philip Kendall
    Commented Nov 22, 2021 at 17:26
  • \$\begingroup\$ GraphicConverter can do all that. \$\endgroup\$
    – Tetsujin
    Commented Nov 22, 2021 at 18:17
  • \$\begingroup\$ @PhilipKendall, Yes, you got it right. I mean exactly that. \$\endgroup\$
    – Asmat Ali
    Commented Nov 22, 2021 at 18:38
  • 1
    \$\begingroup\$ This is a nice little programming project. Since you mention PHP and Java, why don't you just write your own piece of software? \$\endgroup\$
    – osullic
    Commented Nov 22, 2021 at 22:40
  • 2
    \$\begingroup\$ The canonical answer to this is to use ImageMagick in a shell script (IM also has PHP and Java bindings, if necessary). \$\endgroup\$
    – xenoid
    Commented Nov 23, 2021 at 9:40

1 Answer 1

1
\$\begingroup\$

PHP has the imagecrop and imagescale functions, so it should be trivial to cobble together a loop to process a batch of files.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.