Home > Backend Development > PHP Tutorial > PHP example code for zooming pictures

PHP example code for zooming pictures

WBOY
Release: 2016-07-25 08:55:19
Original
1033 people have browsed it
  1. include('SimpleImage.php');
  2. $image = new SimpleImage();
  3. $image->load('picture.jpg');
  4. $image->resize (250,400);
  5. $image->save('picture2.jpg');?>
Copy the code

2, set the width, and scale proportionally

  1. include('SimpleImage.php');
  2. $image = new SimpleImage();
  3. $image->load('picture.jpg');
  4. $image-> resizeToWidth(250);
  5. $image->save('picture2.jpg');?>
Copy code

3, set height, scale proportionally

  1. include('SimpleImage.php');
  2. $image = new SimpleImage();
  3. $image->load('picture.jpg');
  4. $image-> resizeToHeight(500);
  5. $image->save('picture2.jpg');
  6. $image->resizeToHeight(200);
  7. $image->save('picture3.jpg');?>
Copy the code

4, scale it to 50%

  1. include('SimpleImage.php');
  2. $image = new SimpleImage();
  3. $image->load('picture.jpg');
  4. $image-> scale(50);
  5. $image->save('picture2.jpg');?>
Copy the code

5, and output it directly to the screen after scaling

  1. header('Content-Type: image/jpeg');
  2. include('SimpleImage.php');
  3. $image = new SimpleImage();
  4. $image->load ('picture.jpg');
  5. $image->resizeToWidth(150);
  6. $image->output();?>
Copy code

Instructions: SimpleImage.php Get it from the download link provided at the beginning of this article.

>>>> Articles you may be interested in: Example reference for php proportional scaling of images PHP tool for scaling images in equal proportions SimpleImage example learning php code example for batch zooming images



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template