If you have a blog or a website with a lot of content sometimes the images can take a toll on the load time of the pages. Hvis du har en blogg eller et nettsted med mye innhold ganger bildene kan ta en toll på lastetiden på sidene. There are a number of steps you can take to speed things up. Det finnes en rekke ting du kan gjøre for å øke hastigheten ting opp. If you analyze the loading of your website you might notice that the images take up a huge part of the load time. Hvis du analyserer lastingen av webområdet du kanskje merke at bildene tar opp en stor del av lastetiden. Let's take a look at how you can compress your .png images to improve on this figure. La oss ta en titt på hvordan du kan komprimere. PNG-bilder for å bedre på dette tallet.
We'll use the tool pngcrush for this purpose. pngcrush is a free and open source command line tool that, as the name suggests, compresses PNG images. Vi bruker verktøyet pngcrush til dette formålet. Pngcrush er en fri og åpen kildekode kommandolinje-verktøy som, som navnet antyder, komprimerer PNG-bilder. Take a look at the projects website website for detailed information on how to use it. for detaljert informasjon om hvordan du bruker den. We will cover the basics in this article. Vi dekker det grunnleggende i denne artikkelen.
Installation Installasjon
Most modern distributions of Linux such as Fedora and Ubuntu have pngcrush available directly in their default repositories. De fleste moderne distribusjoner av Linux som Fedora og Ubuntu har pngcrush tilgjengelig direkte i sine standard repositories. So, to install it on you Ubuntu computer execute the following command: Så, for å installere det på Ubuntu maskinen du kjører følgende kommando:
# sudo apt-get install pngcrush Sudo apt-get install pngcrush
On Fedora do the following: På Fedora gjøre følgende:
# yum install pngcrush # Yum installere pngcrush
Usage Usage
pngcrush optimizes a PNG graphics file by reducing the size of the files IDAT chunk. pngcrush optimaliserer et PNG-grafikk fil ved å redusere størrelsen på filene IDAT chunk. The process is not simple. Prosessen er ikke enkel. The great thing about pngcrush is that the authors of the tool have simplified things for you. Det flotte med pngcrush er at forfatterne av verktøyet har forenklet ting for deg. They ship it with a great option – brute . De sender det med et godt alternativ - dyr. When you use this option you effectively tell pngcrush to try and use the most suitable method to compress the image at hand. Når du bruker dette alternativet du effektivt fortelle pngcrush å prøve og bruke den mest hensiktsmessige metoden for å komprimere bildet for hånden. There are about 114 different filters that can be used, so this option is mighty useful. Det er omtrent 114 forskjellige filtre som kan benyttes, slik at dette alternativet er veldig nyttig. Here's how you would use it to compress an image: Her ser du hvordan du ville bruke den til å komprimere et bilde:
# pngcrush -brute -e “.compressed.png” image01.png # Pngcrush-brute-e ". Compressed.png" image01.png
The two options used here are -brute which I just explained, and -e . De to alternativene som brukes her er-dyr som jeg nettopp forklarte, og-e. The second option tells pngcrush what extension to add the the filenames. Det andre alternativet forteller pngcrush hva utvidelsen å legge til filnavnene. So after the process of crushing is complete the compressed version of the file image01.png will be called image01.compressed.png . Så etter prosessen med knusende er fullført den komprimerte versjonen av filen image01.png vil bli kalt image01.compressed.png. you can change the extension if you like. Du kan endre filtypen hvis du vil.
You can also slightly modify the above command to compress several PNG files in a directory. Du kan også lett endre det over kommandoen for å komprimere flere PNG-filer i en katalog. Execute the following command: Utfør følgende kommando:
# pngcrush -brute -d “/var/www/html/website/images/” *.png # Pngcrush-brute-d "/ var / www / html / website / images /" *. png
The above command uses a new option, -d . Ovennevnte kommandoen bruker et nytt alternativ,-d. This option tells pngcrush where to place the compressed image files after the compression is complete. Dette alternativet forteller pngcrush hvor du vil plassere den komprimerte bildefiler når komprimeringen er fullført. The above command will compress all the PNG file in the current directory and place them in /var/www/html/website/images/ . Det over kommandoen vil komprimere alle PNG-fil i gjeldende katalog og plassere dem i / var / www / html / website / images /.
I strongly suggest that you read up more about this tool and its options on the projects website. Jeg anbefaler sterkt at du leser mer om dette verktøyet og dets alternativer på prosjekter nettsted. There are a lot of options that might help you speed up the process of compression or do a better job of it. Det finnes en rekke alternativer som kan hjelpe deg å fremskynde prosessen med kompresjon eller gjøre en bedre jobb med det. Put the new images into your website and watch your pages load faster. Sett de nye bildene på webområdet ditt og se sidene lastes raskere.























0 Responses 0 Responses
Stay in touch with the conversation, subscribe to the Hold kontakten med samtalen, abonnere på RSS feed for comments on this post RSS feed for kommentarer til dette innlegget . .