如何在不创建重击图像的情况下更改codeigniter中上传图像的大小?

时间:2016-02-12 14:38:04

标签: php codeigniter codeigniter-2 codeigniter-3

我们可以生成上传图片的不同重击。 这使得该图像的几个副本。 我只想上传一张图片。 但鉴于此,它必须提供不同的尺寸。 有谁知道怎么做?

1 个答案:

答案 0 :(得分:1)

Use PHP library called for f in *.xml; do echo "Processing ${f%.*} file.."; //truncate the .xml extention and load the xml file for job creation java -jar jenkins-cli.jar -s http://server:8080/jenkins create-job ${f%.*} < $f done . phpThumb() uses the GD library to create thumbnails from images on the fly.

you can dynamically create image thumbnails

phpThumb()

usage in View:

<?php

function image_thumb( $image_path, $height, $width )
 {
    $CI =& get_instance();

    // Path to image thumbnail
    $image_thumb = dirname( $image_path ) . '/' . $height . '_' . $width . '.jpg';

    if ( !file_exists( $image_thumb ) ) {
        // LOAD LIBRARY
        $CI->load->library( 'image_lib' );

        // CONFIGURE IMAGE LIBRARY
        $config['image_library']    = 'gd2';
        $config['source_image']     = $image_path;
        $config['new_image']        = $image_thumb;
        $config['maintain_ratio']   = TRUE;
        $config['height']           = $height;
        $config['width']            = $width;
        $CI->image_lib->initialize( $config );
        $CI->image_lib->resize();
        $CI->image_lib->clear();
    }

    return '<img src="' . dirname( $_SERVER['SCRIPT_NAME'] ) . '/' . $image_thumb . '" />';
}