SlideShare uma empresa Scribd logo
1 de 21
Baixar para ler offline
Image Optimisation
for WebApps
Nil Portugués Caldero6th October 2014
Existing solutions
Used either during dev or production deploy stage:
● Symfony2: Assetic Bundle
● NodeJS: github.com/gruntjs/grunt-contrib-imagemin
● Ruby/RoR: github.com/toy/image_optim
Existing solution problems
● Not a real-time solution.
● Waiting for images does not scale. Slow deployment.
● No strategy!
Existing requirements
Device diversity: phone, tablet, PC require a strategy.
● Different presentation layers (media queries). Needs
Strategy.
● Different design requirements. Needs Strategy.
● Fast multi-device UX. Needs Strategy.
Is a consistency model used in distributed computing to
achieve high availability that informally guarantees that, if no
new updates are made to a given data item, eventually all
accesses to that item will return the last updated value.
Source: Wikipedia
Strategy: eventual consistency
Image Service
Send image to optimise to Queue
(if image is not in database)
Model
Extract and fetch optimized images
(if any) for the current View
Solution: Conceptual
Queue with Image Optimisation workers
Controller
Use the best available image.
View
Renders HTML
Background process:
Model: Add abstraction layer
● Separate image assets from the application by extracting.
● Replace image asset for references. Best way, md5 file
contents hash. This will be our image token.
● Store image references and relevant data in a persistence
layer (eg: SQL table or MongoDB document)
Model: Add abstraction layer
<!-- $html will be transformed to $processedHtml -->
<img src="http://example.com/path/to/image/image.jpg" style="
border:2px solid red" data-attribute="example1">
<!-- $processedHtml -->
{{IMG|6fd86da74659f04253285e853af26845|style="border:2px solid
red"|data-attribute="example1"}}
Image Service: Send to queue
● Use queues to resize images (optional) and optimise them.
● Queue system have drivers for many languages.
○ RabbitMQ
○ HornetQ
○ Apache ActiveMQ
○ Apache Apollo
○ Apache Qpid
○ ...
Controller: Use best image available
Fetch the best image possible using the reference:
○ If image has not been processed, use original.
○ If image has been processed, used optimised version.
Replace image token with the most performant image for the
current browser and device.
Queue workers
● The more queue workers, the faster images will be
processed.
● Priority queues can be set depending on criteria to speed up.
● CPU usage for these machines will be high.
● These machines should be able to write to a CDN server.
Application Code
Image
detokenizer
Queue
enqueuer
Image table
(image tokens)
Solution: architecture
Consistency model + high availability + distributed computing
Queue workers
Runs optimizer
script
Queue
System
CDN
(FileSystem)
n m
n m
Optimiser Strategy: The Tools
● Image optimisation tools are very specialised.
● Yet they are dumb, cannot work together.
● So let’s fix it and make them play together, as one.
Optimiser Strategy: The Tools
● JPG: jpegoptim, libjpeg-progs
● PNG: pngout, pngtools, advpng, pngcrush, optipng,
pngquant
● GIF: gifsicle
● SVG: SVGCleaner
● WebP: Google’s image format + encoder.
Optimiser Strategy: Big Picture
● Changing file format (eg: PNG to JPG, JPG to WEBP, GIF to
PNG) is absolutely OK.
● Lossless conversion is default, except for PNG to JPG.
● Run image optimizers in parallel...
● … so we can compare output file size and keep the smallest.
Optimiser Strategy: JPG
● Convert input image to have both progressive and baseline
versions JPGs.
● Remove EXIF and meta-data.
● Do JPG to WEBP conversion for supported browsers
● Compare output and keep the smallest JPG and WEBP if
smaller than produced JPG.
Optimiser Strategy: PNG
● Try reduce channels, from 32 to 24 to 8 bits when possible,
depending on the image colors.
● Alpha files 32 bits usually works as 24 bits
● Re-compress PNG with an optimized LWZ compressor.
Optimiser Strategy: GIF
● Try re-compression.
● If single-framed GIF, go for a PNG, usually produces smaller
file sizes.
● For animated GIF, just try frame optimization. No PNG.
Optimiser Strategy: SVG
● Clean it up using SVG Cleaner client.
● Compare output and keep the smallest.
Optimiser Strategy: The worker
● Runs the script. Returns a JSON straight from command-line
to worker.
● Worker reads the JSON and picks up the best image.
● Upload to CDN.
● Adds to the database the optimised version/s reference plus
additional data such as mime-type.
Questions?

Mais conteúdo relacionado

Semelhante a Image optimization strategy for multi-device web apps

Photo echance. Problems. Solutions. Ideas
Photo echance. Problems. Solutions. Ideas Photo echance. Problems. Solutions. Ideas
Photo echance. Problems. Solutions. Ideas Andrew Nikishaev
 
IRJET- Compress Image without Losing Image Quality using nQuant Library
IRJET-  	  Compress Image without Losing Image Quality using nQuant LibraryIRJET-  	  Compress Image without Losing Image Quality using nQuant Library
IRJET- Compress Image without Losing Image Quality using nQuant LibraryIRJET Journal
 
GPU Renderfarm with Integrated Asset Management & Production System (AMPS)
GPU Renderfarm with Integrated Asset Management & Production System (AMPS)GPU Renderfarm with Integrated Asset Management & Production System (AMPS)
GPU Renderfarm with Integrated Asset Management & Production System (AMPS)Budianto Tandianus
 
Orthogonal Matching Pursuit in 2D for Java with GPGPU Prospectives
Orthogonal Matching Pursuit in 2D for Java with GPGPU ProspectivesOrthogonal Matching Pursuit in 2D for Java with GPGPU Prospectives
Orthogonal Matching Pursuit in 2D for Java with GPGPU ProspectivesMatt Simons
 
EFL: Scaling From the Embedded World to the Desktop
EFL: Scaling From the Embedded World to the DesktopEFL: Scaling From the Embedded World to the Desktop
EFL: Scaling From the Embedded World to the DesktopSamsung Open Source Group
 
Project presentation image compression by manish myst, ssgbcoet
Project presentation image compression by manish myst, ssgbcoetProject presentation image compression by manish myst, ssgbcoet
Project presentation image compression by manish myst, ssgbcoetManish Myst
 
A holistic approach to web performance
A holistic approach to web performanceA holistic approach to web performance
A holistic approach to web performanceAustin Gil
 
From Hours to Minutes: The Journey of Optimizing Mask-RCNN and BERT Using MXNet
From Hours to Minutes: The Journey of Optimizing Mask-RCNN and BERT Using MXNetFrom Hours to Minutes: The Journey of Optimizing Mask-RCNN and BERT Using MXNet
From Hours to Minutes: The Journey of Optimizing Mask-RCNN and BERT Using MXNetEric Haibin Lin
 
Performance Test Automation With Gatling
Performance Test Automation  With GatlingPerformance Test Automation  With Gatling
Performance Test Automation With GatlingKnoldus Inc.
 
Deep Dive: Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
Deep Dive: Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech TalksDeep Dive: Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
Deep Dive: Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech TalksAmazon Web Services
 
Deep Dive on Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
Deep Dive on Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech TalksDeep Dive on Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
Deep Dive on Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech TalksAmazon Web Services
 
Image optimization and you
Image optimization and youImage optimization and you
Image optimization and youJohannes Siipola
 
Korea linuxforum2014 html5game-sangseoklim
Korea linuxforum2014 html5game-sangseoklimKorea linuxforum2014 html5game-sangseoklim
Korea linuxforum2014 html5game-sangseoklimSang Seok Lim
 
Alex_Vlachos_Advanced_VR_Rendering_Performance_GDC2016
Alex_Vlachos_Advanced_VR_Rendering_Performance_GDC2016Alex_Vlachos_Advanced_VR_Rendering_Performance_GDC2016
Alex_Vlachos_Advanced_VR_Rendering_Performance_GDC2016Alex Vlachos
 

Semelhante a Image optimization strategy for multi-device web apps (20)

Photo echance. Problems. Solutions. Ideas
Photo echance. Problems. Solutions. Ideas Photo echance. Problems. Solutions. Ideas
Photo echance. Problems. Solutions. Ideas
 
Flowframes
FlowframesFlowframes
Flowframes
 
#PDR15 - Pebble Graphics
#PDR15 - Pebble Graphics#PDR15 - Pebble Graphics
#PDR15 - Pebble Graphics
 
Project report
Project reportProject report
Project report
 
IRJET- Compress Image without Losing Image Quality using nQuant Library
IRJET-  	  Compress Image without Losing Image Quality using nQuant LibraryIRJET-  	  Compress Image without Losing Image Quality using nQuant Library
IRJET- Compress Image without Losing Image Quality using nQuant Library
 
GPU Renderfarm with Integrated Asset Management & Production System (AMPS)
GPU Renderfarm with Integrated Asset Management & Production System (AMPS)GPU Renderfarm with Integrated Asset Management & Production System (AMPS)
GPU Renderfarm with Integrated Asset Management & Production System (AMPS)
 
Orthogonal Matching Pursuit in 2D for Java with GPGPU Prospectives
Orthogonal Matching Pursuit in 2D for Java with GPGPU ProspectivesOrthogonal Matching Pursuit in 2D for Java with GPGPU Prospectives
Orthogonal Matching Pursuit in 2D for Java with GPGPU Prospectives
 
EFL: Scaling From the Embedded World to the Desktop
EFL: Scaling From the Embedded World to the DesktopEFL: Scaling From the Embedded World to the Desktop
EFL: Scaling From the Embedded World to the Desktop
 
Project presentation image compression by manish myst, ssgbcoet
Project presentation image compression by manish myst, ssgbcoetProject presentation image compression by manish myst, ssgbcoet
Project presentation image compression by manish myst, ssgbcoet
 
A holistic approach to web performance
A holistic approach to web performanceA holistic approach to web performance
A holistic approach to web performance
 
From Hours to Minutes: The Journey of Optimizing Mask-RCNN and BERT Using MXNet
From Hours to Minutes: The Journey of Optimizing Mask-RCNN and BERT Using MXNetFrom Hours to Minutes: The Journey of Optimizing Mask-RCNN and BERT Using MXNet
From Hours to Minutes: The Journey of Optimizing Mask-RCNN and BERT Using MXNet
 
Gatling
Gatling Gatling
Gatling
 
Performance Test Automation With Gatling
Performance Test Automation  With GatlingPerformance Test Automation  With Gatling
Performance Test Automation With Gatling
 
Deep Dive: Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
Deep Dive: Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech TalksDeep Dive: Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
Deep Dive: Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
 
Deep Dive on Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
Deep Dive on Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech TalksDeep Dive on Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
Deep Dive on Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
 
(2) gui drawing
(2) gui drawing(2) gui drawing
(2) gui drawing
 
Ping Pong Pad
Ping Pong PadPing Pong Pad
Ping Pong Pad
 
Image optimization and you
Image optimization and youImage optimization and you
Image optimization and you
 
Korea linuxforum2014 html5game-sangseoklim
Korea linuxforum2014 html5game-sangseoklimKorea linuxforum2014 html5game-sangseoklim
Korea linuxforum2014 html5game-sangseoklim
 
Alex_Vlachos_Advanced_VR_Rendering_Performance_GDC2016
Alex_Vlachos_Advanced_VR_Rendering_Performance_GDC2016Alex_Vlachos_Advanced_VR_Rendering_Performance_GDC2016
Alex_Vlachos_Advanced_VR_Rendering_Performance_GDC2016
 

Último

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Último (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Image optimization strategy for multi-device web apps

  • 1. Image Optimisation for WebApps Nil Portugués Caldero6th October 2014
  • 2. Existing solutions Used either during dev or production deploy stage: ● Symfony2: Assetic Bundle ● NodeJS: github.com/gruntjs/grunt-contrib-imagemin ● Ruby/RoR: github.com/toy/image_optim
  • 3. Existing solution problems ● Not a real-time solution. ● Waiting for images does not scale. Slow deployment. ● No strategy!
  • 4. Existing requirements Device diversity: phone, tablet, PC require a strategy. ● Different presentation layers (media queries). Needs Strategy. ● Different design requirements. Needs Strategy. ● Fast multi-device UX. Needs Strategy.
  • 5. Is a consistency model used in distributed computing to achieve high availability that informally guarantees that, if no new updates are made to a given data item, eventually all accesses to that item will return the last updated value. Source: Wikipedia Strategy: eventual consistency
  • 6. Image Service Send image to optimise to Queue (if image is not in database) Model Extract and fetch optimized images (if any) for the current View Solution: Conceptual Queue with Image Optimisation workers Controller Use the best available image. View Renders HTML Background process:
  • 7. Model: Add abstraction layer ● Separate image assets from the application by extracting. ● Replace image asset for references. Best way, md5 file contents hash. This will be our image token. ● Store image references and relevant data in a persistence layer (eg: SQL table or MongoDB document)
  • 8. Model: Add abstraction layer <!-- $html will be transformed to $processedHtml --> <img src="http://example.com/path/to/image/image.jpg" style=" border:2px solid red" data-attribute="example1"> <!-- $processedHtml --> {{IMG|6fd86da74659f04253285e853af26845|style="border:2px solid red"|data-attribute="example1"}}
  • 9. Image Service: Send to queue ● Use queues to resize images (optional) and optimise them. ● Queue system have drivers for many languages. ○ RabbitMQ ○ HornetQ ○ Apache ActiveMQ ○ Apache Apollo ○ Apache Qpid ○ ...
  • 10. Controller: Use best image available Fetch the best image possible using the reference: ○ If image has not been processed, use original. ○ If image has been processed, used optimised version. Replace image token with the most performant image for the current browser and device.
  • 11. Queue workers ● The more queue workers, the faster images will be processed. ● Priority queues can be set depending on criteria to speed up. ● CPU usage for these machines will be high. ● These machines should be able to write to a CDN server.
  • 12. Application Code Image detokenizer Queue enqueuer Image table (image tokens) Solution: architecture Consistency model + high availability + distributed computing Queue workers Runs optimizer script Queue System CDN (FileSystem) n m n m
  • 13. Optimiser Strategy: The Tools ● Image optimisation tools are very specialised. ● Yet they are dumb, cannot work together. ● So let’s fix it and make them play together, as one.
  • 14. Optimiser Strategy: The Tools ● JPG: jpegoptim, libjpeg-progs ● PNG: pngout, pngtools, advpng, pngcrush, optipng, pngquant ● GIF: gifsicle ● SVG: SVGCleaner ● WebP: Google’s image format + encoder.
  • 15. Optimiser Strategy: Big Picture ● Changing file format (eg: PNG to JPG, JPG to WEBP, GIF to PNG) is absolutely OK. ● Lossless conversion is default, except for PNG to JPG. ● Run image optimizers in parallel... ● … so we can compare output file size and keep the smallest.
  • 16. Optimiser Strategy: JPG ● Convert input image to have both progressive and baseline versions JPGs. ● Remove EXIF and meta-data. ● Do JPG to WEBP conversion for supported browsers ● Compare output and keep the smallest JPG and WEBP if smaller than produced JPG.
  • 17. Optimiser Strategy: PNG ● Try reduce channels, from 32 to 24 to 8 bits when possible, depending on the image colors. ● Alpha files 32 bits usually works as 24 bits ● Re-compress PNG with an optimized LWZ compressor.
  • 18. Optimiser Strategy: GIF ● Try re-compression. ● If single-framed GIF, go for a PNG, usually produces smaller file sizes. ● For animated GIF, just try frame optimization. No PNG.
  • 19. Optimiser Strategy: SVG ● Clean it up using SVG Cleaner client. ● Compare output and keep the smallest.
  • 20. Optimiser Strategy: The worker ● Runs the script. Returns a JSON straight from command-line to worker. ● Worker reads the JSON and picks up the best image. ● Upload to CDN. ● Adds to the database the optimised version/s reference plus additional data such as mime-type.