Welcome Guest, Not a member yet? Register   Sign In
How To Use Resized İmages in view?
#1

[eluser]Unknown[/eluser]
Hi
There is a problem about using dynamic resized image in the view pages..

For example all of my pictures are 400x300 and I want to every image show the thumbnail 100x75 and when the any image clicked 400x300 image shows the popup.

I got the image resized but how to use this image in anypage_view.php

Be careful I dont want to save thumb. ı want use original file and create dynamic resize and use the pages..
#2

[eluser]Jelmer[/eluser]
You could write a controller that outputs the resized image, for instance by setting the dynamic_output to true while using the Image Manipulation class. And then you could use it like this (with a controller "images", a function "thumbs" and an image "image_name.jpg"):
Code:
<img src="&lt;?php echo site_url('images/thumbs/image_name/jpg'); ?&gt;" />

Though I wouldn't recommend this, when creating lots of thumbs it will consume loads of megabytes of memory and most servers won't like that. It'll also slow your pageload considerably.
#3

[eluser]jacobc[/eluser]
If you're going to displaying a lot then you should probably consider saving them...
Then next time the page is visited you can check if they have already been created and save the memory.
#4

[eluser]jedd[/eluser]
Entirely agree with jacobc.

I just wrote a gallery system (web front end to plug into KPhotoAlbum), but not using CI. I tried gd2 and imagemagick functions, and for some things had to drop out to system() calls too. It was just infeasible, even on a very low traffic site (my own) and a reasonably powerful server (dual-core, 4GB) to call up relatively modest sized files (5MP and 7MP JPEGs) and convert them on the fly.

I ended up developing a very basic cache system and generated thumbnails, medium, and large images. Works a treat and wasn't especially difficult to construct. My cache management system is pretty easy, though, as I'm coming from a known collection of all available images (KPA uses an XML backend) and built a small admin function that will go through to check for stale cache files. But really, the thing flies compared what it was like doing it dynamically.

You should run a few benchmarks for resizing your images.




Theme © iAndrew 2016 - Forum software by © MyBB