有人可以建议 php 中最好的图像调整大小脚本吗?

发布于 2024-07-24 06:34:03 字数 41 浏览 3 评论 0原文

你好,

我需要 php 中所有类型的图像调整大小脚本

HI

i need all types of images resize script in php

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

病女 2024-07-31 06:34:03

WideImage 是一个面向对象的图像处理库,用 PHP 5 编写。它是一个纯 PHP 库,除了 GD2 扩展之外不需要任何外部库。

我曾经在一个私人项目中使用过它,对我来说效果相当好。

样品

// Chaining operations:
wiImage::load('image.png')->resize(50, 30)->saveToFile('new-image.jpg', 30);

// Load, crop, flip and output to browser in one line (no http headers included):
echo wiImage::load('image.png')->crop(30, 30, '50%', '50%')->flip()->asString('png');

// watermarking
$img = wiImage::load('pic.jpeg');
$watermark = wiImage::load('watermark.jpg');
$new_img = $img->merge($watermark, 40, 80);

WideImage is an object-oriented library for image manipulation, written in/for PHP 5. It's a pure-PHP library and doesn't require any external libraries apart from the GD2 extension.

i used it in a private project once, worked reasonably well for me.

Samples

// Chaining operations:
wiImage::load('image.png')->resize(50, 30)->saveToFile('new-image.jpg', 30);

// Load, crop, flip and output to browser in one line (no http headers included):
echo wiImage::load('image.png')->crop(30, 30, '50%', '50%')->flip()->asString('png');

// watermarking
$img = wiImage::load('pic.jpeg');
$watermark = wiImage::load('watermark.jpg');
$new_img = $img->merge($watermark, 40, 80);
恰似旧人归 2024-07-31 06:34:03

如果您使用的是 UNIX 系统,我强烈建议您查看 ImageMagick 及其各种界面。 世界上最快、使用最广泛的图像处理工具。

具体来说,请查看 PHP 接口之一 MagickWand

If you are on a unix system, I highly recommend checking out ImageMagick and its various interfaces. Fastest and most widely used image processing tools in the world.

Specifically, check out MagickWand, one of the PHP interfaces.

早乙女 2024-07-31 06:34:03

我肯定会使用 ImageMagick 的任何包装器而不是 PHP GD 库,因为后者要求您将内存设置得相当高,而且如果您在网络酒店租用地方,则并不总是允许您这样做。 除了调整大小之外,ImageMagick 还具有许多功能。

I would definitely use any wrapper for ImageMagick instead of the PHP GD lib, as the latter require you to set memory pretty darn high, and you're not always allowed to if you rent place at webhotels. ImageMagick has many features as well besides just resizing.

但可醉心 2024-07-31 06:34:03

有一个简单易用的开源库,名为 PHP Image Magician,它具有一些不错的功能和文档。

基础用法示例:

$magicianObj = new imageLib('racecar.jpg');
$magicianObj -> resizeImage(100, 200, 'crop');
$magicianObj -> saveImage('racecar_small.png');

There a simple to use, open source library called PHP Image Magician that has some nice features and documentation.

Example of basis usage:

$magicianObj = new imageLib('racecar.jpg');
$magicianObj -> resizeImage(100, 200, 'crop');
$magicianObj -> saveImage('racecar_small.png');
栩栩如生 2024-07-31 06:34:03

显而易见的基于 PHP 的解决方案是使用 GD 读取文件、获取尺寸、计算新尺寸、缩放图像并输出。

前提是您有 GD 扩展,即:http://de3.php。 net/manual/en/book.image.php

还有 Imagic 扩展,可以非常简单地调整大小: http://de3.php.net/manual/en/function.imagick-scaleimage.php

The obvious PHP-based solution would be reading the file with GD, getting the dimensions, calculating the new dimensions, scaling the image and outputting it.

Provided you have the GD extension, that is: http://de3.php.net/manual/en/book.image.php

There's also the Imagic extension which allows pretty straightforward resizing: http://de3.php.net/manual/en/function.imagick-scaleimage.php

赤濁 2024-07-31 06:34:03

这非常简单:https://github.com/elboletaire/Watimage

$wm = new Watimage('test.png');
// Resize image to 400x400px
$wm->resize(array('type' => 'resizecrop', 'size' => 400));
// Flip it horitzontally
$wm->flip('horizontal');
// Rotate 90 degrees
$wm->rotate(90);
// Generate and save image
$wm->generate('test2.png');

This is quite easy: https://github.com/elboletaire/Watimage

$wm = new Watimage('test.png');
// Resize image to 400x400px
$wm->resize(array('type' => 'resizecrop', 'size' => 400));
// Flip it horitzontally
$wm->flip('horizontal');
// Rotate 90 degrees
$wm->rotate(90);
// Generate and save image
$wm->generate('test2.png');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文