Tinify API support with laravel

Related tags

API laravel tinify-api
Overview

ysTinify-laravel

Tinify API support with laravel

Latest Version on Packagist

Install

$ composer require yasmuru/ys-tinify-laravel

Add this to your config/app.php,

under "providers":

        yasmuru\LaravelTinify\LaravelTinifyServiceProvider::class,

under "aliases":

        'Tinify' => yasmuru\LaravelTinify\Facades\Tinify::class

And set a env variable TINIFY_APIKEY with your tinypng api key.

If you want to directly upload the image to aws s3, you need set the env variables of following with your aws s3 credentials.

    S3_KEY=
    S3_SECRET=
    S3_REGION=
    S3_BUCKET=

Examples

	$result = Tinify::fromFile('\path\to\file');


	$result = Tinify::fromBuffer($source_data);

	$result = Tinify::fromUrl($image_url);

	/** To save as File **/
	$result->toFile('\path\to\save');

	/** To get image as data **/
	$data = $result->toBuffer();
	$s3_result = Tinify::fileToS3('\path\to\file', $s3_bucket_name, '/path/to/save/in/bucket');

	$s3_result = Tinify::bufferToS3($source_data, $s3_bucket_name, '/path/to/save/in/bucket');

	$s3_result = Tinify::urlToS3($image_url, $s3_bucket_name, '/path/to/save/in/bucket');

	/** To get the url of saved image **/
	$s3_image_url = $s3_result->location();
	$s3_image_width = $s3_result->width();
	$s3_image_hight = $s3_result->height();

NOTE: All the images directly save to s3 is publicably readable. And you can set permissions for s3 bucket folder in your aws console to make sure the privacy of images.

You might also like...
API documentation API SCB EASY APP

SCB-API-EASY V3.0 API documentation SIAM COMMERCIAL BANK PUBLIC COMPANY LTD. API SCB Easy V3 endpoint = https://fasteasy.scbeasy.link 1.0. Get balance

Courier API adalah project API untuk mengetahui ongkos kirim Logistik-logistik pengiriman barang antar kota & International
Courier API adalah project API untuk mengetahui ongkos kirim Logistik-logistik pengiriman barang antar kota & International

Courier API Courier API adalah project API untuk mengetahui ongkos kirim Logistik-logistik pengiriman barang antar kota (dalam negeri) & International

LaraBooks API - Simple API for iOS SwiftUI app tests.

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Simple PHP API client for tube-hosting.com rest API

Tube-Hosting API PHP client Explanation This PHP library is a simple api wrapper/client for the tube-hosting.com api. It is based on the provided docu

Best resources restful api for developers (with JSON:API standar specification design)

List API Best resources restful api for developers (with JSON:API standar specification design). API Resource Endpoint Name Resource Description Al Qu

Chargebee API PHP Client (for API version 2 and Product Catalog version 2.0)

chargebee-php-sdk Overview This package provides an API client for Chargebee subscription management services. It connects to Chargebee REST APIs for

GraphQL API to Studio Ghibli REST API

GhibliQL GhibliQL is a GraphQL wrapper to the Studio Ghibli REST API Usage First, you'll need a GraphQL client to query GhibliQL, like GraphQL IDE Con

A Laravel Fractal package for building API responses, giving you the power of Fractal with Laravel's elegancy.
A Laravel Fractal package for building API responses, giving you the power of Fractal with Laravel's elegancy.

Laravel Responder is a package for building API responses, integrating Fractal into Laravel and Lumen. It can transform your data using transformers,

Laravel API 文档生成器,可以将基于 Laravel 项目的项目代码,自动生成 json 或 md 格式的描述文件。

Thresh Laravel API 文档生成器,可以将基于 Laravel 项目的项目代码,自动生成 json 或 md 格式的描述文件。 安装 $ composer require telstatic/thresh -vvv 功能 生成 Markdown 文档 生成 Postman 配置文件 生

Comments
  • Laravel 7 support

    Laravel 7 support

    Cant be installed on laravel 7

     Problem 1
        - Conclusion: remove laravel/framework v7.21.0
        - Conclusion: don't install laravel/framework v7.21.0
        - yasmuru/ys-tinify-laravel v1.0 requires illuminate/support ~5.2 -> satisfiable by illuminate/support[5.2.x-dev, 5.3.x-dev, 5.4.x-dev, 5.5.x-dev, 5.6.x-dev, 5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, 5.8.x-dev, v5.2.0, v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28, v5.2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7, v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.5.44, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9, v5.7.0, v5.7.1, v5.7.10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.36, v5.8.4, v5.8.8, v5.8.9].
        - yasmuru/ys-tinify-laravel v1.0.1 requires illuminate/support ~5.2 -> satisfiable by illuminate/support[5.2.x-dev, 5.3.x-dev, 5.4.x-dev, 5.5.x-dev, 5.6.x-dev, 5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, 5.8.x-dev, v5.2.0, v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28, v5.2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7, v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.5.44, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9, v5.7.0, v5.7.1, v5.7.10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.36, v5.8.4, v5.8.8, v5.8.9].
        - yasmuru/ys-tinify-laravel v1.0.2 requires illuminate/support ~5.2 -> satisfiable by illuminate/support[5.2.x-dev, 5.3.x-dev, 5.4.x-dev, 5.5.x-dev, 5.6.x-dev, 5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, 5.8.x-dev, v5.2.0, v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28, v5.2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7, v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.5.44, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9, v5.7.0, v5.7.1, v5.7.10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.36, v5.8.4, v5.8.8, v5.8.9].
        - don't install illuminate/support 5.5.x-dev|don't install laravel/framework v7.21.0
        - don't install illuminate/support 5.6.x-dev|don't install laravel/framework v7.21.0
        - don't install illuminate/support 5.7.17|don't install laravel/framework v7.21.0
        - don't install illuminate/support 5.7.18|don't install laravel/framework v7.21.0
        - don't install illuminate/support 5.7.19|don't install laravel/framework v7.21.0
        - don't install illuminate/support 5.7.x-dev|don't install laravel/framework v7.21.0
        - don't install illuminate/support 5.8.x-dev|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.5.0|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.5.16|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.5.17|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.5.2|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.5.28|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.5.33|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.5.34|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.5.35|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.5.36|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.5.37|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.5.39|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.5.40|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.5.41|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.5.43|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.5.44|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.0|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.1|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.10|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.11|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.12|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.13|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.14|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.15|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.16|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.17|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.19|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.2|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.20|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.21|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.22|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.23|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.24|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.25|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.26|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.27|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.28|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.29|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.3|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.30|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.31|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.32|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.33|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.34|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.35|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.36|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.37|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.38|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.39|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.4|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.5|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.6|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.7|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.8|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.6.9|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.7.0|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.7.1|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.7.10|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.7.11|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.7.15|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.7.2|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.7.20|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.7.21|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.7.22|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.7.23|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.7.26|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.7.27|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.7.28|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.7.3|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.7.4|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.7.5|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.7.6|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.7.7|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.7.8|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.7.9|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.0|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.11|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.12|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.14|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.15|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.17|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.18|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.19|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.2|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.20|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.22|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.24|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.27|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.28|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.29|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.3|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.30|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.31|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.32|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.33|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.34|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.35|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.36|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.4|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.8|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.8.9|don't install laravel/framework v7.21.0
        - don't install illuminate/support 5.2.x-dev|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.2.0|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.2.19|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.2.21|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.2.24|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.2.25|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.2.26|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.2.27|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.2.28|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.2.31|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.2.32|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.2.37|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.2.43|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.2.45|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.2.6|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.2.7|don't install laravel/framework v7.21.0
        - don't install illuminate/support 5.3.x-dev|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.3.0|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.3.16|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.3.23|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.3.4|don't install laravel/framework v7.21.0
        - don't install illuminate/support 5.4.x-dev|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.4.0|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.4.13|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.4.17|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.4.19|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.4.27|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.4.36|don't install laravel/framework v7.21.0
        - don't install illuminate/support v5.4.9|don't install laravel/framework v7.21.0
        - Installation request for laravel/framework (locked at v7.21.0, required as ^7.0) -> satisfiable by laravel/framework[v7.21.0].
        - Installation request for yasmuru/ys-tinify-laravel ^1.0 -> satisfiable by yasmuru/ys-tinify-laravel[v1.0, v1.0.1, v1.0.2].
    
    
    Installation failed, reverting ./composer.json to its original content.
    
    opened by robertnicjoo 3
  • Problem when using php artisan config:cache

    Problem when using php artisan config:cache

    I’m using Tinify with my Laravel application. Part of my deployment process is to optimize my configuration environment by using php artisan config:cache. This speeds my app’s load time as well as access to configuration variables. Unfortunately, one of the side effects of using this is that the env(‘’) function no longer works to retrieve environment variable settings. You instead need to create a file in /config and pre-load all of your .env settings. Here’s the best explanation I could find of the procedure: https://scotch.io/tutorials/how-to-use-laravel-config-files

    The TinifyService class uses env(‘’) in its constructor. Since I’m using php artisan config:cache, this always returns a null string.

    So … what I’m asking is if you could modify your code to include a config/tinify.php file that pulls in the TINIFY_APIKEY from the .env file. You would then need to load the .env value in the new config/tinify.php file and modify the TinifyService class to use config(‘tinify.apikey’) (or similar).

    This approach would then work correctly whether the user implements the config cache or not.

    Something similar to below:

    Current TinifyService constructor

    class TinifyService {

        /**
         * Get api key from env, fail if any are missing.
         * Instantiate API client and set api key.
         *
         * @throws Exception
         */
        public function __construct() {
            $this->apikey = env('TINIFY_APIKEY');
            if(!$this->apikey) {
                throw new \InvalidArgumentException('Please set TINIFY_APIKEY environment variables.');
            }
            $this->client = new Tinify();
            $this->client->setKey($this->apikey);
        }
    

    Proposed TinifyService constructor

    class TinifyService {
        /**
         * Get api key from env, fail if any are missing.
         * Instantiate API client and set api key.
         *
         * @throws Exception
         */
        public function __construct() {
            $this->apikey = config(‘tinify.apikey’);
            if(!$this->apikey) {
                throw new \InvalidArgumentException('Please set TINIFY_APIKEY environment variables.');
            }
            $this->client = new Tinify();
            $this->client->setKey($this->apikey);
        }
     
    

    Proposed config/tinify.php

    <?php
     
    return [
                    ‘apikey’ => env(‘TINIFY_APIKEY’),
    ];
    
    opened by kc22033 0
  • Correction TinifyService.php

    Correction TinifyService.php

    I could not see how much is compressed per month. Now i can! $tinifymonth = Tinify::compressionCount(); // compressed per month $tinifymonth = 500 - Tinify::compressionCount(); // compressions left

    opened by aktaumag 0
  • Getting error Call to undefined method Tinify\Tinify::fromFile()

    Getting error Call to undefined method Tinify\Tinify::fromFile()

    Hey, I am new to Laravel environment. Kindly assist me. I have installed your package but i am not able to use it in the controller where i need to compress the images. Can you please assist me how to include the class or method so that i can compress images in controller. Below is the sample code of my public controller that i am trying to do:

    namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Http\Requests; use App\Http\Controllers\Controller;

    use Tinify\Tinify;

    class TinifyController extends Controller {

    public function index(){ $uncompressed = public_path("images\uncompressed\img.jpeg"); $compressed = public_path("images\compressed\img.jpeg"); $result = Tinify::fromFile($uncompressed); /** To save as File **/ $result->toFile($compressed); echo "Done!"; die; }

    }

    opened by ManvinderSingh005 1
Releases(v1.0.2)
Owner
Murugan D
Principal Software Engineer
Murugan D
It helps to provide API support to projects. It is Simple, Safe and Fast.

apiservice It helps to provide API support to projects. It is Simple, Safe and Fast. Setup composer create-project mind/apiservice or After downloadin

Ali Yılmaz 5 Nov 3, 2022
Simple and effective multi-format Web API Server to host your PHP API as Pragmatic REST and / or RESTful API

Luracast Restler ![Gitter](https://badges.gitter.im/Join Chat.svg) Version 3.0 Release Candidate 5 Restler is a simple and effective multi-format Web

Luracast 1.4k Dec 14, 2022
Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application

CORS Middleware for Laravel Implements https://github.com/asm89/stack-cors for Laravel About The laravel-cors package allows you to send Cross-Origin

Fruitcake 6.2k Jan 8, 2023
Laravel api tool kit is a set of tools that will help you to build a fast and well-organized API using laravel best practices.

Laravel API tool kit and best API practices Laravel api tool kit is a set of tools that will help you to build a fast and well-organized API using lar

Ahmed Esa 106 Nov 22, 2022
A PHP library to support implementing representations for HATEOAS REST web services.

Hateoas A PHP library to support implementing representations for HATEOAS REST web services. Installation Working With Symfony Usage Introduction Conf

William Durand 998 Dec 5, 2022
EXPERIMENTAL plugin extending WPGraphQL to support querying (Gutenberg) Blocks as data, using Server Side Block registries to map Blocks to the GraphQL Schema.

WPGraphQL Block Editor This is an experimental plugin to work toward compatiblity between the WordPress Gutenberg Block Editor and WPGraphQL, based on

WPGraphQL 29 Nov 18, 2022
A robust JSON decoder/encoder with support for schema validation.

A robust wrapper for json_encode()/json_decode() that normalizes their behavior across PHP versions, throws meaningful exceptions and supports schema validation by default.

Bernhard Schussek 356 Dec 21, 2022
This API aims to present a brief to consume a API resources, mainly for students in the early years of Computer Science courses and the like.

Simple PHP API v.1.0 This API aims to present a brief to consume a API resources, mainly for students in the early years of Computer Science courses a

Edson M. de Souza 14 Nov 18, 2021
微信支付 API v3 的 PHP Library,同时也支持 API v2

微信支付 WeChatPay OpenAPI SDK [A]Sync Chainable WeChatPay v2&v3's OpenAPI SDK for PHP 概览 微信支付 APIv2&APIv3 的Guzzle HttpClient封装组合, APIv2已内置请求数据签名及XML转换器,应

null 275 Jan 5, 2023
This API provides functionality for creating and maintaining users to control a simple To-Do-List application. The following shows the API structure for users and tasks resources.

PHP API TO-DO-LIST v.2.0 This API aims to present a brief to consume a API resources, mainly for students in the early years of Computer Science cours

Edson M. de Souza 6 Oct 13, 2022