Giter Site home page Giter Site logo

peferron / srcset Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 4 KB

Generate scaled-down versions of an image and the corresponding <img srcset="..."> HTML.

License: MIT License

Shell 100.00%
retina-ready srcset html5 hidpi image-processing imagemagick

srcset's Introduction

srcset

srcset is a bash script that generates scaled-down versions of an image, and the corresponding <img srcset="..."> HTML.

Usage

srcset <path-to-image> <width> <width> ...

Widths are specified in pixels, with an optional xN multiplier suffix. For example, 1000 and 500x2 are equivalent.

Example

$ ls -lS
total 7648
-rw-r--r--  1 peferron  staff  3913850 Mar  9 18:29 picture.jpg

$ srcset picture.jpg 500 500x2 5000
Generated picture_500x500.jpg
Generated picture_1000x1000.jpg
Generated picture_2300x2300.jpg (full-size copy)

<img srcset="picture_500x500.jpg 500w,
picture_1000x1000.jpg 1000w,
picture_2300x2300.jpg 2300w"
sizes=""
src="picture.jpg">

HTML copied to clipboard.

$ ls -lS
total 18744
-rw-r--r--  1 peferron  staff  3913850 Mar  9 18:29 picture.jpg
-rw-r--r--  1 peferron  staff  3913850 Apr 12 19:16 picture_2300x2300.jpg
-rw-r--r--  1 peferron  staff  1358584 Apr 12 19:16 picture_1000x1000.jpg
-rw-r--r--  1 peferron  staff   402301 Apr 12 19:16 picture_500x500.jpg

Dependencies

Imagemagick.

srcset's People

Contributors

peferron avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.