How to resize image by imagine extension in yii2
<p>I use the bellow function to resize images after upload to show on my post.
but it works just for images larger than 500px 300px. when I upload image smaller than this size, my website images row breaks down.</p>

<pre><code>use yii\imagine\Image;    
public function upload() {
            $this-&gt;pictureFile-&gt;saveAs('../files/upload/' . $this-&gt;pictureFile-&gt;baseName . '.' . $this-&gt;pictureFile-&gt;extension);

            Image::thumbnail('../files/upload/' . $this-&gt;pictureFile, 500, 300)
                    -&gt;save('../files/upload/thumbnail-500x300/' . $this-&gt;pictureFile-&gt;baseName . '.' . $this-&gt;pictureFile-&gt;extension, 
                            ['quality' =&gt; 70]);
            unlink('../files/upload/' . $this-&gt;pictureFile-&gt;baseName . '.'  . $this-&gt;pictureFile-&gt;extension);
        }
</code></pre>