PHPackages                             gozoro/yii2-preview - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. gozoro/yii2-preview

ActiveYii2-extension[Image &amp; Media](/categories/media)

gozoro/yii2-preview
===================

Yii2 component for resizing, cropping and creating preview image and saving to cache folder.

v1.0.1(5y ago)170MITPHPPHP &gt;=5.5.9

Since Nov 20Pushed 5y ago1 watchersCompare

[ Source](https://github.com/gozoro/yii2-preview)[ Packagist](https://packagist.org/packages/gozoro/yii2-preview)[ Docs](https://github.com/gozoro/yii2-preview)[ RSS](/packages/gozoro-yii2-preview/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (5)Used By (0)

yii2-preview
============

[](#yii2-preview)

Yii2 component for resizing, cropping and creating preview image and saving to cache folder. Used only GD library.

Installation
------------

[](#installation)

```
	composer require gozoro/yii2-preview

```

Configuration
-------------

[](#configuration)

```
'components' => [

	...

	'preview' => [
		'class' => 'gozoro\preview\PreviewComponent',
		'previewPath' => '/var/www/site/www/preview_cache',
		'previewWebPath' => '/preview_cache',
		'defaultPreview' => 'default.jpg',
	],

	...

],
```

Usage
-----

[](#usage)

```
$filename = "/var/www/site/images/image.jpg";

//Get preview url
$url = Yii::$app->preview->create($filename)->resize(300,300)->crop(200,200)->cache()->url;
print '';

//Get preview path
$imagePath = Yii::$app->preview->create($filename)->resize(300,300)->crop(200,200)->cache()->filename;

//Save As
Yii::$app->preview->create($filename)->resize(300,300)->crop(200,200)->saveAs('/var/www/site/images/image2.jpg');
```

Other methods see the link [gozoro/image](https://github.com/gozoro/image)

Configuration for PDF
---------------------

[](#configuration-for-pdf)

```
'components' => [

	...

	'preview' => [
		'class' => 'gozoro\preview\PreviewComponent',
		'previewPath' => '/var/www/site/www/preview_cache',
		'previewWebPath' => '/preview_cache',
		'on beforeOpen' => function($event)
		{
			if($event->extension == 'pdf')
			{
				$pdf_file = $event->filename;
				$hash = 'pdf_'.md5($pdf_file);

				$pdf_image = '/var/www/site/www/preview_cache/'.$hash.'.jpg';

				if(!file_exists($pdf_image))
				{
					system( "/usr/bin/nice -2 /usr/bin/gs -dNOPAUSE -q -dBATCH -dSAFER -sDEVICE=jpeg "
						. " -dJPEGQ=100 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r150 -dFirstPage=1 -dLastPage=1 "
						. " -sOutputFile=".$pdf_image." ".$pdf_file   );

				}
				$event->filename = $pdf_image;
			}
		},
	],

	...

],
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~166 days

Total

4

Last Release

1867d ago

Major Versions

v0.1.2 → v1.0.02021-03-03

### Community

Maintainers

![](https://www.gravatar.com/avatar/a273abe77cdd4c74270a90320efbeb4d4dfb3ceac5b4d505ce2ccafddf1e06e0?d=identicon)[gozoro](/maintainers/gozoro)

---

Top Contributors

[![gozoro](https://avatars.githubusercontent.com/u/13768280?v=4)](https://github.com/gozoro "gozoro (11 commits)")

---

Tags

imageresizeyii2previewcropresizingcropping

### Embed Badge

![Health badge](/badges/gozoro-yii2-preview/health.svg)

```
[![Health](https://phpackages.com/badges/gozoro-yii2-preview/health.svg)](https://phpackages.com/packages/gozoro-yii2-preview)
```

###  Alternatives

[sadovojav/yii2-image-thumbnail

Yii2 image thumbnail component

2142.1k](/packages/sadovojav-yii2-image-thumbnail)[raoul2000/yii2-jcrop-widget

This extension is a wrapper for the jQuery Image Cropping Plugin (jcrop)

10248.3k2](/packages/raoul2000-yii2-jcrop-widget)[noam148/yii2-image-resize

A Yii2 component for resizing images (on the fly)

1144.6k7](/packages/noam148-yii2-image-resize)[demi/cropper

Yii2 wrapper for Image Cropper javascript library

1328.7k1](/packages/demi-cropper)[ayvazyan10/nova-imagic

Imagic is a Laravel Nova field package that allows for image manipulation capabilities, such as cropping, resizing, quality adjustment, and WebP conversion. It utilizes the powerful Intervention Image class for image manipulation.

144.3k1](/packages/ayvazyan10-nova-imagic)[somehow-digital/typo3-media-processing

Media Processing

101.1k](/packages/somehow-digital-typo3-media-processing)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
