Download the PHP package renepardon/croppa without Composer

On this page you can find all versions of the php package renepardon/croppa. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package croppa

Croppa

Packagist Build Status

Croppa is an thumbnail generator bundle for Laravel 4.x, 5.x and Lumen (local storage only). It follows a different approach from libraries that store your thumbnail dimensions in the model, like Paperclip. Instead, the resizing and cropping instructions come from specially formatted urls. For instance, say you have an image with this path:

/uploads/09/03/screenshot.png

To produce a 300x200 thumbnail of this, you would change the path to:

/uploads/09/03/screenshot-300x200.png

This file, of course, doesn't exist yet. Croppa listens for specifically formatted image routes and build this thumbnail on the fly, outputting the image data (with correct headers) to the browser instead of the 404 response.

At the same time, it saves the newly cropped image to the disk in the same location (the "…-300x200.png" path) that you requested. As a result, all future requests get served directly from the disk, bybassing PHP and all that overhead. In other words, your app does not boot just to serve an image. This is a differentiating point compared to other, similar libraries.

Since 4.0, Croppa lets images be stored on remote disks like S3, Dropbox, FTP and more thanks to Flysystem integration.

Installation

Server Requirements:

Laravel:

  1. Add Croppa to your project: composer require renepardon/croppa
  2. If using Laravel < 5.5:
    • Add Croppa as a provider in your app config's provider list: 'Bkwld\Croppa\ServiceProvider'
    • Add the facade to your app config's aliases: 'Croppa' => 'Bkwld\Croppa\Facade'

Lumen:

  1. Add Croppa to your project: composer require renepardon/croppa
  2. Enable facades and add the facade in bootstrap/app.php: class_alias('Bkwld\Croppa\Facade', 'Croppa');.
  3. Add the provider in bootstrap/app.php: $app->register('Bkwld\Croppa\ServiceProvider');.
  4. Create a directory on the project root called 'config' and copy the config file there then rename it to croppa.php.
  5. Add a Laravel helpers file like this one to the files autoloading section in your composer.json.

Nginx

When using Nginx HTTP server boilerplate configs, add in the location block for Media, located in file h5bp/location/expires.conf.

Configuration

Read the source of the config file for documentation of the config options. Here are some examples of common setups (additional examples can be found here):

You can publish the config file into your app's config directory, by running the following command:

Local src and crops directories

The most common scenario, the src images and their crops are created in the doc_root's "uploads" directory.

Thus, if you have <img src="<?=Croppa::url('/uploads/file.jpg', 200)?>">, the returned URL will be /uploads/file-200x_.jpg, the source image will be looked for at public_path().'/uploads/file.jpg', and the new crop will be created at public_path().'/uploads/file-200x_.jpg'. And because the URL generated by Croppa::url() points to the location where the crop was created, the web server (Apache, etc) will directly serve it on the next request (your app won't boot just to serve an image).

Here is another example:

If you have <img src="<?=Croppa::url('http://domain.com/images/crops/file.jpg', 200, 100)?>">, the returned URL will be http://domain.com/images/crops/file-200x100.jpg, the source image will be looked for at /www/public/images/file.jpg, and the new crop will be created at /www/public/images/crops/file-200x100.jpg.

Src images on S3, local crops

This is a good solution for a load balanced enviornment. Each app server will end up with it's own cache of cropped images, so there is some wasted space. But the web server (Apache, etc) can still serve the crops directly on subsequent crop requests.

Thus, if you have <img src="<?=Croppa::url('/uploads/file.jpg', 200, 100)?>">, the returned URL will be /uploads/file-200x100.jpg, the source image will be looked for immediately within the S3 bucket that was configured as part of the Flysystem instance, and the new crop will be created at /uploads/file-200x100.jpg.

Usage

The URL schema that Croppa uses is:

/path/to/image-widthxheight-option1-option2(arg1,arg2).ext

So these are all valid:

/uploads/image-300x200.png             // Crop to fit in 300x200
/uploads/image-_x200.png               // Resize to height of 200px
/uploads/image-300x_.png               // Resize to width of 300px
/uploads/image-300x200-resize.png      // Resize to fit within 300x200
/uploads/image-300x200-quadrant(T).png // See the quadrant description below

Croppa::url($url, $width, $height, array($options))

To make preparing the URLs that Croppa expects an easier job, you can use the following view helper:

These are the arguments that Croppa::url() takes:

Croppa::render($cropurl)

If you want to create the image programmatically you can pass to this function the url generated by Croppa::url. This will only create the thumbnail and exit.

or

Croppa::delete($url)

You can delete a source image and all of it's crops (like if a related DB row was deleted) by running:

Croppa::reset($url)

Similar to Croppa::delete() except the source image is preserved, only the crops are deleted.

Console commands

croppa:purge

Deletes ALL crops. This works by scanning the crops_dir recursively and matching all files that have the Croppa naming convention where a corresponding src file can be found. Accepts the following options:

croppa.js

A module is included to prepare formatted URLs from JS. This can be helpful when you are creating views from JSON responses from an AJAX request; you don't need to format the URLs on the server. It can be loaded via Require.js, CJS, or as browser global variable.

croppa.url(url, width, height, options)

Works just like the PHP Croppa::url except for how options get formatted (since JS doesn't have associative arrays).

Run php artisan asset:publish renepardon/croppa to have Laravel copy the JS to your public directory. It will go to /public/packages/renepardon/croppa/js by default.

History

Read the Github project releases for release notes.

This bundle uses PHPThumb to do all the image resizing. "Crop" is equivalent to it's adaptiveResize() and "resize" is … resize(). Support for interacting with non-local disks provided by Flysystem.


All versions of croppa with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2.0
illuminate/console Version 4 - 5
illuminate/support Version 4 - 5
illuminate/routing Version 4 - 5
league/flysystem Version ~1.0
symfony/http-foundation Version 2 - 4
symfony/http-kernel Version 2 - 4
weotch/phpthumb Version ^1.0.5
intervention/image Version ^2.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package renepardon/croppa contains the following files

Loading the files please wait ....