نمایش نتایج: از شماره 1 تا 2 , از مجموع 2

موضوع: مشکل در کش شدن عکس

  1. #1
    عضو جدید
    تاریخ عضویت
    Mar 2012
    نوشته ها
    98
    تشکر تشکر کرده 
    26
    تشکر تشکر شده 
    11
    تشکر شده در
    11 پست

    پیش فرض مشکل در کش شدن عکس

    سلام دوستان

    من از کد زیر برای ریساز کردن عکس و کم حجم کردن عکس استفاده میکنم . مشکل این هست عکساا کش نمیشه !!

    ممنون میشم راهنمایی کنید .



    <?php
    /*
    image.php

    A simple image resize script that resizes images given either a maxsize, maxheight or maxwidth

    Usage
    =====
    -to resize an image to a max of 400px along the longest side
    <img src="image.php?size=400&amp;file=filename.jpg" />

    -to resize an image to a height of 400px (width will be kept to the right aspect ratio)
    <img src="image.php?size=h400&amp;file=filename.jpg" />

    -to resize an image to a width of 400px (height will be kept to the right aspect ratio)
    <img src="image.php?size=w400&amp;file=filename.jpg" />

    This script is very simple and should not be considered for production use. There are many image
    resizing scripts available that have better error checking, support for other formats (this only
    supports jpg) and have image caching. Cachine makes a HUGE difference to overall speed.

    @author Harvey Kane harvey@harveykane.com

    */

    /* Get information from Query String */
    if (!isset($_GET['file']) || !isset($_GET['size'])) {
    echo "Image variables not specified correctly";
    exit();
    }

    $file = $_GET['file'];
    $size = $_GET['size'];

    /* Get image dimensions and ratio */
    list($width, $height) = getimagesize($file);
    $ratio = $width / $height;

    /* Decide how we should resize image - fixed width or fixed height */
    if (substr($size, 0, 1) == 'h') {
    $type = 'fixedheight';
    } elseif (substr($size, 0, 1) == 'w') {
    $type = 'fixedwidth';
    } elseif ($height > $width) {
    $type = 'fixedheight';
    } else {
    $type = 'fixedwidth';
    }

    /* Calculate new dimensions */
    if ($type == 'fixedheight') {
    $new_width = floor(str_replace('h','',$size) * $ratio);
    $new_height = str_replace('h','',$size);
    } else {
    $new_width = str_replace('w','',$size);
    $new_height = floor(str_replace('w','',$size) / $ratio);
    }

    /* Resample */
    $new_image = imagecreatetruecolor($new_width, $new_height);
    $old_image = imagecreatefromjpeg($file);
    imagecopyresampled($new_image, $old_image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

    /* Output */
    //header('Content-type: image/jpeg');
    imagejpeg($new_image, null, 100);
    exit();
    ?>


  2. # ADS




     

  3. #2
    عضو انجمن shahinmq آواتار ها
    تاریخ عضویت
    Oct 2012
    محل سکونت
    اصفهان
    نوشته ها
    266
    تشکر تشکر کرده 
    231
    تشکر تشکر شده 
    695
    تشکر شده در
    470 پست

    پیش فرض پاسخ : مشکل در کش شدن عکس

    کد رو در htaccess اضافه کنید :

    در ضمن کدتون هم در قالب کد قرار بدید نه نقل قول تا راحت تر خونده بشه

    کد:
    ## EXPIRES CACHING ##
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access 1 year"
    ExpiresByType image/jpeg "access 1 year"
    ExpiresByType image/gif "access 1 year"
    ExpiresByType image/png "access 1 year"
    ExpiresByType text/css "access 1 month"
    ExpiresByType text/x-javascript "access 1 month"
    ExpiresByType text/javascript "access 1 month"
    ExpiresByType image/x-icon "access 1 year"
    ExpiresDefault "access 30 days"
    </IfModule>

اطلاعات موضوع

کاربرانی که در حال مشاهده این موضوع هستند

در حال حاضر 1 کاربر در حال مشاهده این موضوع است. (0 کاربران و 1 مهمان ها)

مجوز های ارسال و ویرایش

  • شما نمیتوانید موضوع جدیدی ارسال کنید
  • شما امکان ارسال پاسخ را ندارید
  • شما نمیتوانید فایل پیوست کنید.
  • شما نمیتوانید پست های خود را ویرایش کنید
  •