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. Ja jums ir blogs vai mājas lapa ar daudz satura dažreiz attēlus var veikt nodevu par ielādes laiks no lapas. There are a number of steps you can take to speed things up. Ir soļu varat veikt, lai paātrinātu lietu up numuru. If you analyze the loading of your website you might notice that the images take up a huge part of the load time. Ja jūs analizēt iekraušanu jūsu mājas jūs ievērosiet, ka bildes aizņem lielu daļu no ielādes laiku. Let's take a look at how you can compress your .png images to improve on this figure. Let's to apskatīt, kā jūs varat saspiest jūsu. Png attēlus, lai uzlabotu šo skaitli.
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. Mēs izmantosim rīks pngcrush šim nolūkam. Pngcrush ir bezmaksas un atvērtā koda komandrindas rīks, kas, kā norāda nosaukums, kompreses PNG attēlus. Take a look at the projects Veikt apskatīt projekti website mājas lapa for detailed information on how to use it. Sīkāku informāciju par to, kā to izmantot. We will cover the basics in this article. Mēs uz šajā pantā pamati.
Installation Uzstādīšana
Most modern distributions of Linux such as Fedora and Ubuntu have pngcrush available directly in their default repositories. Lielākā daļa mūsdienu sadalījumi Linux, piemēram, Fedora un Ubuntu nav pngcrush pieejami tieši to noklusējuma krātuves. So, to install it on you Ubuntu computer execute the following command: Tātad, lai to instalēt jūsu Ubuntu datorā izpildīt šādu komandu:
# sudo apt-get install pngcrush # Sudo apt-get install pngcrush
On Fedora do the following: Par Fedora izdarīt šādi:
# yum install pngcrush # Yum install pngcrush
Usage Lietojums
pngcrush optimizes a PNG graphics file by reducing the size of the files IDAT chunk. pngcrush optimizē PNG grafikas fails, samazinot izmēra failiem IDAT rieciens. The process is not simple. Process nav vienkāršs. The great thing about pngcrush is that the authors of the tool have simplified things for you. Lieliska lieta par pngcrush ir tas, ka ir rīks autori ir vienkāršotas lietas, par jums. They ship it with a great option – brute . To sūtītie to ar lielu variants - lops. When you use this option you effectively tell pngcrush to try and use the most suitable method to compress the image at hand. Kad izmantojat šo opciju, jūs faktiski pateikt pngcrush mēģināt izmantot vispiemērotāko metodi, lai saspiestu attēlu puses. There are about 114 different filters that can be used, so this option is mighty useful. Ir aptuveni 114 dažādi filtri, kurus var izmantot, lai šī iespēja ir varens noderīga. Here's how you would use it to compress an image: Lūk, kā jūs varētu izmantot, lai saspiestu attēls:
# pngcrush -brute -e “.compressed.png” image01.png # Pngcrush-lops-e ". Compressed.png" image01.png
The two options used here are -brute which I just explained, and -e . Divas iespējas izmanto šeit ir-necilvēks ko es tikko izskaidroja un-e. The second option tells pngcrush what extension to add the the filenames. Otrais variants stāsta pngcrush to paplašināšanu, lai pievienotu failu nosaukumi. So after the process of crushing is complete the compressed version of the file image01.png will be called image01.compressed.png . Arī pēc procesa sasmalcināšana ir pilnīga saspiesto versiju fails image01.png sauks image01.compressed.png. you can change the extension if you like. Jūs varat mainīt pagarinājumu, ja vēlaties.
You can also slightly modify the above command to compress several PNG files in a directory. Jūs varat nedaudz mainīt iepriekš minēto komandu, lai saspiestu vairākas PNG failus direktorijā. Execute the following command: Izpildīt šādu komandu:
# pngcrush -brute -d “/var/www/html/website/images/” *.png # Pngcrush-lops-D "/ var / www / html / website / images /" *. png
The above command uses a new option, -d . Iepriekš minēto komandu izmanto jaunu iespēju,-D. This option tells pngcrush where to place the compressed image files after the compression is complete. Šī opcija stāsta pngcrush kur novietot saspiesto attēlu faili pēc saspiešanas ir pabeigta. The above command will compress all the PNG file in the current directory and place them in /var/www/html/website/images/ . Iepriekš komanda saspiest visu PNG failu pašreizējā direktorijā un jāieliek in / var / www / html / website / images /.
I strongly suggest that you read up more about this tool and its options on the projects website. There are a lot of options that might help you speed up the process of compression or do a better job of it. Ir iespējas, kas varētu jums palīdzēt paātrināt procesu kompresijas vai darīt labāku darbu ir daudz. Put the new images into your website and watch your pages load faster. Ielieciet jaunu attēlus jūsu tīmekļa vietnē un skatīties jūsu lapas parādīsies ātrāk.























0 Responses 0 Atbildes
Stay in touch with the conversation, subscribe to the Uzturēt kontaktus ar sarunu, abonēt RSS feed for comments on this post RSS barību komentārus par šo ziņu . .