search
HomePHP LibrariesPicture libraryMaster PHP library for operating pictures
master PHP library for optimizing images


<?php
namespace ImageOptimizer\TypeGuesser;
class ExtensionTypeGuesser implements TypeGuesser
    public function guess($filepath)
    {
        $ext = strtolower(pathinfo($filepath, PATHINFO_EXTENSION));
        switch($ext) {
            case 'png':
                return self::TYPE_PNG;
            case 'gif':
                return self::TYPE_GIF;
            case 'jpg':
            case 'jpeg':
                return self::TYPE_JPEG;
            default:
                return self::TYPE_UNKNOWN;
        }
    }
}

Manipulate images: remove unnecessary colors, pixels, etc., for example, change the image from large to small. The requirement for web images is to publish images of the highest possible quality in the shortest possible transmission time. Therefore, when designing and processing web page images, it is required that the images have the highest possible resolution and the smallest possible size, so that the download speed of the images can be the fastest. To do this, the image must be optimized.


Disclaimer

All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn

Related Article

How to add a picture border to the picture and adapt the picture size_html/css_WEB-ITnoseHow to add a picture border to the picture and adapt the picture size_html/css_WEB-ITnose

24Jun2016

Please tell me how to add a picture border to the picture and adjust the picture size

[Emergency help] After the large picture obtains the small picture through coordinates, how to remove the border on the small picture? _html/css_WEB-ITnose[Emergency help] After the large picture obtains the small picture through coordinates, how to remove the border on the small picture? _html/css_WEB-ITnose

24Jun2016

[Emergency help] After the large picture obtains the small picture through coordinates, how to remove the border on the small picture?

CSS3 vertical mouse move to picture picture scrolling, graphic menu code_html/css_WEB-ITnoseCSS3 vertical mouse move to picture picture scrolling, graphic menu code_html/css_WEB-ITnose

24Jun2016

CSS3 vertical mouse move to picture picture scrolling, graphic menu code

How to output multiple sizes of images in phpHow to output multiple sizes of images in php

06Jul2016

{Code...} The picture above is a picture with a width of 480 and a height of 270. Remove the suffix !w480h270 to access the original picture. Question: 1. How is this kind of picture usually stored on the server? Is it just the original picture? 2. Add the suffix !w480h270 to generate corresponding thumbnails. How thumbnails are generally stored...

When inserting a picture into td in html, why the picture cannot fill the entire td_html/css_WEB-ITnoseWhen inserting a picture into td in html, why the picture cannot fill the entire td_html/css_WEB-ITnose

24Jun2016

When inserting a picture into a TD in HTML, why can’t the picture fill the entire TD?

Image display problem_html/css_WEB-ITnoseImage display problem_html/css_WEB-ITnose

24Jun2016

Picture display problem

See all articles