Giter Club home page Giter Club logo

php-image-cache's People

Contributors

4selected avatar alegueleres avatar bitdeli-chef avatar mhor avatar neemzy avatar nielse63 avatar salkhwlani avatar solleer avatar tjefford avatar williamcarril-trendi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-image-cache's Issues

Check if the new image is larger than the old image ?

Hi,

I noticed that some times the size of the image actually increases.
For ex an image 170 KB increase to 204 KB.

This happens rarely but it would be good if there was an inbuilt way to check if any image compression took place.

Final image URL is broken

Web server: NGINX
PHP Version: 5.5.9-1ubuntu4.14

I am getting this error Final image URL is broken. The page looks like this
page
There should be 100 images displayed but it dies at the third.

It is returning this url exampleImage
There should be a / between the mediapage.zips.me and core, however it is a local image so I don't see why it should even need the host name.

How I am doing this is,

On the top of each page I am calling another page which contains the setup of the class

<?php
    //Calls the php-image things
    include 'test.php';

?>

Inside test.php

<?php 
    require_once 'core/classes/ImageCache.php';
    $imagecache = new ImageCache();
?>

Image page

<?php 
    //Directory NON-CACHED images are stored in
    $dir    =   "i/";

    //Array of files in the Directory
    $files1 =   scandir($dir);
    //Used to limit results (100's of images)
    $count = 0;
    foreach ($files1 as $key) {
        //If the file name is longer than 3 chars and the count is less 
        //than the amount of images I want displayed.
        if (strlen($key) > 3 && $count <= 100){
            $count++;
            //dir2 is the directory/nameofFile.extension
            //Eg: i/testImage.png
            $dir2   =   $dir.''.$key;
            $info = new SplFileInfo($key);
            //Image Cache variable
            $cached_src = $imagecache->cache($dir2);
?>
    <tr>
        <td>
            <!-- Link for light box for full resolution image -->
            <a href="<?php echo $dir2;?>" data-popup="lightbox">
                <!-- src of cached image is outputted and the alt is the name of the uncached image. -->
                <img src="<?php echo $cached_src;?>" alt="<?php echo $key;?>" class="img-rounded img-preview">
            </a>
        </td>
        <!-- More table stuff... -->
    </tr>

<?php
        } //End If
    } //End for
?>

Docs do not match code at all

The docs located at:

http://nielse63.github.io/php-image-cache/

Do not match the functionality at all. For example:

$image = new ImageCache(
    $filebase = '', $dir = null, $create_dir = true, $opts = array()
);
/**
 * @param $filebase (string) - The base URL that will be included in the final output for the image source; primarily used if you want the image source to be an absolute URL; defaults to relative.
 * @param $dir (string/null) - The base directory that houses the image being compressed; defaults to the location of ImageCache.php.
 * @param $create_dir (bool) - Whether or not to create a new directory for the compressed images; defaults to "true"
 * @param $opts (array) - An array of available options that the user can include to the overwrite default settings.  Mostly just for forward-compatibility at the moment.
 */

In the code the constructor actually accepts 3 parameters, 2 of which will be deprecated soon!

Very confusing.

Error behaviour is also completely undocumented.

Cannot Output the Compressed image on WAMP server

I am having trouble displaying the compressed Image on my local server(WAMP).
The image compression works perfectly, but when I try to echo out the image in tag, it displays a broken image.

Heres my folder structure:

sample (root folder)
-images (inside sample)
-cached (inside images, here's where the cached file goes)
-f3ccdd27d2000e3f9255a7e3e2c48800.jpg(cached image)
-1.jpg (Image to be compressed, inside images folder)
-ImageCache.php (inside sample)
-index.php (inside sample)

Thanks!

Blank page

Hey,

I am experiencing an issue.
I can successfully shrink and cache the image but I am getting a blank page.

How can I fix this?

Update: Apparently this is caused by an error made by ImageCache.php: "Final image URL is broken".
I used this guide to solve it

Empty caches on local system

I am trying to use PHP Image Cache. But have run into some issues. I have managed to get the script to somehow function (I think). But it seems that my images aren’t being cached correctly. The files are 0kb in size. I am developing on a local system running MAMP (not sure if this is the issue). Here is how i execute the script:

http://pastebin.com/EJJmkcvi
AND
http://pastebin.com/dStWtUGR

Path of my files:

top / images / letters / (here is all the images i am trying to cache)
top / images / letters / cached / (here is the 0kb sized images that is being somehow cached)
top / scripts / ImageCache.php
top / scripts / funcs.php

Returned value

Can there be an option for the returned value of the cache function to be the cached image src and not a url version of it.

Error PHP

Hello, I download the latest version, then transfer to my server but when I run the demo I have two PHP error ?

Warning: Unexpected character in input: '' (ASCII = 92) state = 1 in / fximg/new/demo/index.php on line 16

Parse error: syntax error, unexpected T_STRING in / fximg/new/demo/index.php on line 16

What it comes from my version of PHP ? ... or something else!

help me please ;)

Script is not user friendly...

I think your script is not user friendly... just to configure your script we need more time... and there are soo many functions missing.... i really wanted to use your script.. but i keep getting errror message ...and these error error message can be answered only by you.. " Call to undefined function ImageCache\curl_init() in C:\wamp\www\icon\src\ImageCache\ImageCache.php " dont know why have you desghned this?? there is no documentation also.. serioously i wasted my time.. even stack experts could not find solutions for your script bugs...if you really want to make this as popular script.. please write a good documentation, each and every line on how to work on your script... forget about script updation, first let the basic things work...Sorry but that's what i found....

Message: Undefined variable: main_url

private function is404($source) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $main_url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == '404')
return $this->show404();
return false;
}

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: main_url

Filename: ImageCache/ImageCache.php

Line Number: 232

Fix strtotime() empty

The documentation of PHP does not allow strtotime() empty.

Error:
strtotime() expects at least 1 parameter, 0 given

File: /src/ImageCache/ImageCache.php
Line: 197.

Fix:
Add 'now' in strtotime(), or switch to time()

Incorrect work of makesource function on some servers

Hi,

Yesterday I used ImageCache class to cache some images on my website. I noticed, that when $_SERVER['DOCUMENT_ROOT'] = '/', then solution presented currently in ImageCache.php is going to replace all occurences of slash, which results in incorrect source string.

For example, if resulting string should be: /path/to/img , then after using makesource function, we've got: pathtoimg.

I've done some workaround for it, which works for me:

private function makesource( $dir ) {
        $cururl = strtolower( reset( explode( '/', $_SERVER['SERVER_PROTOCOL'] ) ) ) . '://' . $_SERVER['SERVER_NAME'];
        $base = $_SERVER['DOCUMENT_ROOT'];

        if($base == '/')
        {
            $localpath = substr($dir, 1);
        }else{
            $localpath = str_replace( $base, '', $dir );
        }

        return $cururl . $localpath;
}

Best regards,
Mike

JPG (.jpg) not working

I am trying your class with JPG file getting lot of errors

first was "The file you supplied isn't a valid image."

Then I commented the if condition just to check, then got "The image you supply must have a .gif, .jpg/.jpeg, or .png extension." Then I checked "$file_mime_as_ext" and it dump "octet-stream" for jpg file. I know it's some kind of mime problem. Any idea how to fix it?

Thanks in advance

Refresh Image?

Can the class refresh images so user's browsers download the new image every x minutes ?

Image must writable error

../images must writable! is being displayed on the php page

This is the line of code which I believe is giving the problem

$cached_src_one = $imagecache->cache( '../images/background.jpg' );

I am running the php page from where the images folder is found.

image_src on Linux and Silverstripe

I'm using Silverstripe (framework) hosted in a Linux server.
The framework default upload folder name contains a Uppercase Letter ("assets/Uploads").
When we call the method cache(), it uses 'strtolower' in the folder name turning it to "assets/uploads" which generates an error on trying to find the image since its address is wrong. It must keep the uppercase "U" in "Uploads".

Keep the previous format

Hello.
Based on this statement:

imagejpeg( $image, $newlocation, $this->opts['quality'] );

an image is always converted as a JPG image. Why it can't be saved as its previous format?

Bug

Warning: imagejpeg(C:\xampp\htdocs\php-image-cache-master\demo/images/cached/ccc2078020a3fec0056ed59b53a7bf2d.jpeg): failed to open stream: No such file or directory in C:\xampp\htdocs\php-image-cache-master\src\ImageCache\ImageCache.php on line 230
Could not copy image resource.

"It showing error like this how should i give input(Url) please suggest me"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.