Piranha CMS disable image resizing - image

I'm currently building a website with Piranha CMS MVC.
I noticed when I upload an image, the quality gets significantly worse.
I use this to load the image on to my page:
<img class="fullwidthimg" src="#UI.Content(Model.Regions.image.Id)" alt="#Model.Regions.image.Name" />
I'm familiar with HTML/CSS/JS but .NET is still quite new to me.
I was unable to find a solution in the forum or on the Piranha website.

I had the same issue, until i went poking around in the source. I found in the Content class there is a method called SetFileMeta that is used to resize the image.
What I found was a system setting being used as the max width. You can find the setting under System -> Parameters -> IMAGE_MAX_WIDTH. Increasing this number will increase the max width of the image, however, if you set the value to zero, the image will not be resized when it is uploaded.

Related

Woocommerce Catalog Page Image Size

I have changed the theme (to OceanWP). Now the catalog images in the store are no longer displayed as desired. Before the woocommerce_thumbnail was loaded (247x296). Now only the original images are inserted. Now there are differences in the display of these catalog images, which looks unsightly.
I have tried to adjust this via customizer. Here I use the thumbnail width 247 and crop to the aspect ratio 5:6. The catalog images do not respond to these settings in any way.
Then I used the Regenerate Thumbnail plugin to regenerate all the thumbnails. Again no success, everything the same as before.
I saw that for the product images that were still uploaded with the previous theme, the HTML code directly pointed to the desired woocommerce_thumbnail. For the new products uploaded via OceanWP, this is handled with "srcset", which doesn't seem to work properly. (examine the different image-object, higher and smaller once)
My wish is that the products catalog reverts to the appropriate woocommerce_thumbnail. Or, that I can override the previous settings with a code snippet so that the thumbnails are all cropped to the same size again.
I am grateful to anyone for even an approach to fixing the problem.
Regards
Tim

Images in listview are not released from memory when out of view

I am displaying images from the internet in a vertical ListView. I fetch the images using http.get (not using cached network image cuz I do not want to cache the images). Then I insert the image Uint8List into image.memory(). What happens is that as the user scrolls the list and images are loading, the ram keeps increasing until the whole app crashes. Any ideas what to do ?
Yeah, this is the normal behavior. I don't know why exactly. My theory is that the images by default are disposed if the dart objects holding references to them are garbage collected rather then when the widgets are knocked off the widgets tree, but don't take my word for it- that's just my personal reasoning. It may be completely wrong.
To get around this, I use Extended Image pakcage It's constructors take a bool clearMemoryCacheWhenDispose which disposes of images in RAM in scroll lists. You may do that or visit the package code to see how he's doing it, and replicate it.
Other advice I can give is to make sure your images are of the appropriate size. If you are loading your images locally check this part of the documentation to have different dimensions selected for different screen sizes https://flutter.dev/docs/development/ui/assets-and-images#loading-images
If you are fetching your images from network which is more likely, make sure their sizes are appropriate, and have different sizes served if you can. If you don't have control over that set cacheWidth and cacheHeight in Image.memory these will reduce the cached image in memory (RAM). You see by default Flutter caches images in full resolution despite their apparent size in the device/app. For example if you want your image to display in 200x200 box then set cacheWidth to 200 * window.devicePixelRatio.ceil() you will find window in dart:ui, and if you only set cacheWidth, the ratio of your images will remain true. Same true if you only set cacheHeight. Also do use ListView.builder as suggested.
I am disappointed at how little is said about this in Flutter docs. Most of the time people discover this problem when their apps start crashing. Do check your dev tools regularly for memory consumption. It's the best indicator out there.
Cheers and good luck
I was having the same issue and found a fix thanks to #moneer!
Context:
Users in my app can create shared image galleries which can easily contain several hundred images. Those are all displayed in a SliverGrid widget. When users scrolled down the list, too many images were loaded into RAM and the app would crash.
Things I had already implemented:
Image resizing on the server side and getting the appropriate sized images on the client based on the device pixel ratio and the tile size in the gallery
I made sure that my image widgets were properly disposing when out of view, but the memory size kept building up as the user scrolled through all the images anyway
Implement cacheHeight to limit the size of the cached image to the exact size of the displayed image
All these things helped but the app would eventually still crash every time the user scrolled down far enough.
The fix:
After some googling I stumbled upon this thread and tried the extended_image_package as #moneer suggested. Setting the clearMemoryCacheWhenDispose flag to true fixed the issue of the app crashing as it was now properly clearing the images from memory when they were out of view. Hooray! However, in my app users can tap on an image and the app navigates to an image detail page with a nice Hero animation. When navigating back the image would rebuild and this would cause a rebuild 'flicker'. Not that nice to look at and kind of distracting.
I then noticed that there's also an enableMemoryCache flag. I tried setting this to false and that seems to work nicely for me. The Network tab in Dart DevTools seems to show that all images are only fetched from the network once when scrolling up and down the gallery multiple times. The app does not crash anymore.
I'll have to more testing to see if this leads to any performance issues (if you can think of any please let me know).
The final code:
ExtendedImage.network(
_imageUrl,
cacheHeight: _tileDimension,
fit: BoxFit.cover,
cache: true, // store in cache
enableMemoryCache: false, // do not store in memory
enableLoadState: false, // hide spinner
)
I had a similar issue when I loaded images from files in a ListView.
[left-side: old code, right-side: new code]
The first huge improvement for me: not to load the whole list at once
ListView(children:[...]) ---> ListView.builder(...).
The second improvement was that images are no longer loaded at full-size:
Image.file("/path") ---> Image.file("/path", cacheWidth: X, cacheHeight: Y)
These two things solved my memory problems completely
Ideally caching happens kind of by default after some conditions are fulfilled. So its upon your app to be responsible to handle and control how the caching will happen.
Checkout this answer
https://stackoverflow.com/a/24476099/12264865

Website loads image with 1-2 second delay. Could I increase the performance somehow?

recently I made a website for my photography. htttp://www.simotamas.com
I am a newbie, so its not the best site but it works fine for me, I got only one problem, when a site is loaded on a device for the first time, the gallery loading time takes up to 1-2 seconds.
Could you guys please check if I mess up something with the code?
Or should I made the pictures even smaller?
Any way I could increase the loading performance.
I would be really thankful for any advice.
Some points you can consider
Use thumbnails for preview (low resolution) , while clicking load actual image.
Load images of only visible part first then load the images in bottom. (May affect user experience)
if you have cpu power , use any libraries like cache tools or compression tools like
https://nielse63.github.io/php-image-cache/ . benchmark it carefully.
use gzip if you are not using gzip compression for your server.
The fact your website doesn't wait for the image to load is considered a plus (look into asynchronous web page content loading for a good read) that said you should compress your images before uploading them.. tinypng.com is a nice tool for it... But if it's a photography website doing so would reduce picture quality... Try to play with Photoshop save settings to find your ideal compromise between quality and size with respect to "memory" size... Pictures are heavy.. high definition and resolution will obviously result in heavier files to download
Update: another thing you could do is actually display (smaller) thumbnail and only load the full picture on request. I.e: user clicks and image opens in new tab
It would help if you create smaller thumb versions of your images so the browser can initially load these ones for the overview and no need for scaling way to big images down while rendering the page. An image should always be downloaded in the dimension it's going to be presented.

Laravel blade. Best way to show an image size according to the size of the screen

For each record, I have two images, small and large size. What is the best way to show an image size according to the size of the screen?
I know I can use css and mediaquery and show the small or large image using a div display none / block, but in this way, I understand that the user has downloaded both images even if they are not displayed, is that correct? Then, the page load increases. If so, what is the best option to do this?
For this problem the most efficient way is using the User-Agent to detect if a client is desktop, tablet or mobile.
I prefer to use Mobile_Detect or jenssegers/agent (based on Mobile_Detect).
Edit
Recently I installed the Google Pagespeed Module on my server. There is a filter, resize_rendered_image_dimensions, that returns images with sizes of the current client view (exactly what you are looking for).
Some other implementation would be lazyloading with Javascript and adding dimensions to the requested url depending on the viewport sizes.

Codeigniter dompdf image not rendering

I am finding problem in using dompdf with codeigniter, in rendering the image.
Actually my requirement is as follows:
User fills a given form.
He clicks ab button to print the form.
At the same time when he print the form, a pdf version of that
from is to be sent to user.
I am using dompdf for that. It works well, but the logo which is an image is not displayed in view and also in rendered pdf file.
I googled for that, and found that image path should be wrt server and not wrt application.
eg. my image path is /var/www/my_system/images/logo.png.
But it didn't visible. It shows fails to load URL.
I am using dompdf-0.5.2 version.
Please suggest.
Any help would be greatly appriciated.
Your issue appears to be related to the PHP memory limit. You could try increasing the memory limit to prevent issues in the future.
Some image operations can be costly in terms of system memory. dompdf has to do a lot more processing with PNG to support the full feature set. The KB size of the image isn't the determining factor because the memory footprint has more to do with the dimensions of the image.
FYI, it always helps debugging PHP issues to be able to see any errors thrown.

Resources