项目作者: vseventer

项目描述 :
CLI for sharp.
高级语言: JavaScript
项目地址: git://github.com/vseventer/sharp-cli.git
创建时间: 2015-11-04T10:23:04Z
项目社区:https://github.com/vseventer/sharp-cli

开源协议:MIT License

下载


sharp-cli

CLI for sharp, a high performance Node.js image processing module.

Install

$ npm install sharp-cli

Usage

  1. sharp <options> [command..]
  2. Commands:
  3. sharp affine <matrix..> Perform an affine transform on an image
  4. sharp bandbool <operator> Perform a bitwise boolean operation on all input
  5. image channels (bands) to produce a single channel
  6. output image
  7. sharp blur [sigma] Blur the image
  8. sharp boolean <operand> <operator> Perform a bitwise boolean operation with operand
  9. image
  10. sharp clahe <width> <height> Perform contrast limiting adaptive histogram
  11. equalization CLAHE
  12. sharp composite [images..] Composite image(s) over the processed (resized,
  13. extracted etc.) image
  14. sharp convolve <width> <height> <kernel..> Convolve the image with the specified kernel
  15. sharp ensureAlpha [alpha] Ensure the output image has an alpha transparency
  16. channel
  17. sharp extend <top> <bottom> <left> <right> Extends/pads the edges of the image with the provided
  18. background colour
  19. sharp extract <top> <left> <width> <height> Extract a region of the image
  20. sharp extractChannel <channel> Extract a single channel from a multi-channel image
  21. sharp flatten [background] Merge alpha transparency channel, if any, with a
  22. background
  23. sharp flip Flip the image about the vertical Y axis
  24. sharp flop Flop the image about the horizontal X axis
  25. sharp gamma [gamma] [gammaOut] Apply a gamma correction by reducing the encoding
  26. (darken) pre-resize then increasing the encoding
  27. (brighten) post-resize
  28. sharp greyscale Convert to 8-bit greyscale; 256 shades of grey
  29. [aliases: grayscale]
  30. sharp joinChannel <images..> Join one or more channels to the image
  31. sharp linear [multiplier..] Apply the linear formula a × input + b to the image
  32. to adjust image levels
  33. sharp median [size] Apply median filter
  34. sharp modulate Transforms the image using brightness, saturation,
  35. hue rotation, and lightness
  36. sharp negate Produce the "negative" of the image
  37. sharp normalise Enhance output image contrast by stretching its
  38. luminance to cover the full dynamic range
  39. [aliases: normalize]
  40. sharp pipelineColourspace <colourspace> Set the pipeline colourspace
  41. [aliases: pipelineColorspace]
  42. sharp recomb <matrix..> Recomb the image with the specified matrix
  43. sharp removeAlpha Remove alpha channel, if any
  44. sharp resize [width] [height] Resize image to width, height, or width × height
  45. sharp rotate [angle] Rotate the output image
  46. sharp sharpen [sigma] Sharpen the image
  47. sharp threshold [value] Any pixel value greather than or equal to the
  48. threshold value will be set to 255, otherwise it will
  49. be set to 0
  50. sharp tint <rgb> Tint the image using the provided chroma while
  51. preserving the image luminance
  52. sharp tile [size] Use tile-based deep zoom (image pyramid) output
  53. sharp toColourspace <colourspace> Set the output colourspace [aliases: toColorspace]
  54. sharp trim [threshold] Trim pixels from all edges that contain values
  55. similar to the given background color, which defaults
  56. to that of the top-left pixel
  57. sharp unflatten Ensure the image has an alpha channel with all white
  58. pixel values made fully transparent
  59. Global Options
  60. -i, --input Path to (an) image file(s) [array] [required] [default: stdin]
  61. -o, --output Directory or URI template to write the image files to
  62. [string] [required] [default: stdout]
  63. --timeout Number of seconds after which processing will be stopped [number]
  64. Input Options
  65. --animated Read all frames/pages of an animated image [boolean]
  66. --failOn Level of sensitivity to invalid images
  67. [choices: "none", "truncated", "error", "warning"] [default: warning]
  68. --density DPI for vector images [number] [default: 72]
  69. --ignoreIcc Should the embedded ICC profile, if any, be ignored
  70. [boolean] [default: false]
  71. --level Level to extract from a multi-level input (OpenSlide), zero based [number]
  72. --limitInputPixels Do not process input images where the number of pixels (width x height)
  73. exceeds this limit [number] [default: 268402689]
  74. --page Page number to start extracting from for multi-page input [number]
  75. --pages Number of pages to extract for multi-page input [number] [default: 1]
  76. --sequentialRead Use sequential rather than random access where possible
  77. [boolean] [default: false]
  78. --subifd subIFD to extract for OME-TIFF [number] [default: -1]
  79. --unlimited Remove safety features that help prevent memory exhaustion [boolean]
  80. Output Options
  81. -c, --compressionLevel zlib compression level [number] [default: 6]
  82. -f, --format Force output to a given format
  83. [choices: "avif", "gif", "heif", "jpeg", "jpg", "png", "raw", "tiff", "webp"] [default: input]
  84. -m, --metadata, --withMetadata Include all metadata (EXIF, XMP, IPTC) from the input image in the
  85. output image [boolean]
  86. --metadata.density Number of pixels per inch (DPI) [number]
  87. --metadata.exif Object keyed by IFD0, IFD1 etc. of key/value string pairs to write
  88. as EXIF data [default: {}]
  89. --metadata.icc Filesystem path to output ICC profile [string] [default: sRGB]
  90. --metadata.orientation Used to update the EXIF Orientation tag [number]
  91. -p, --progressive Use progressive (interlace) scan [boolean]
  92. -q, --quality Quality [number] [default: 80]
  93. Optimization Options
  94. --adaptiveFiltering Use adaptive row filtering [boolean]
  95. --alphaQuality Quality of alpha layer [number] [default: 80]
  96. --bitdepth Reduce bitdepth to 1, 2, or 4 bit
  97. [choices: 1, 2, 4, 8] [default: 8]
  98. --chromaSubsampling Set to "4:4:4" to prevent chroma subsampling when
  99. quality <= 90
  100. [string] [default: 4:4:4 (AVIF) / 4:2:0]
  101. --colors, --colours Maximum number of palette entries
  102. [number] [default: 256]
  103. --compression Compression options
  104. [choices: "ccittfax4", "deflate", "jpeg", "jp2k", "lzw", "none", "packbits", "webp", "zstd"]
  105. [default: "jpeg"]
  106. --delay Delay(s) between animation frames [number]
  107. --dither Level of Floyd-Steinberg error diffusion
  108. [number] [default: 1.0]
  109. --effort Level of CPU effort to reduce file size
  110. [number] [default: 7 (GIF, PNG) / 4]
  111. --hbitdepth Set bitdepth to 8, 10, or 12 bit
  112. [choices: 8, 10, 12] [default: 8]
  113. --hcompression Compression format
  114. [choices: "hevc", "av1"] [default: "av1"]
  115. --interFrameMaxError Maximum inter-frame error for transparency [number]
  116. --interPaletteMaxError Maximum inter-palette error for palette reuse
  117. [number]
  118. --loop Number of animation iterations [number] [default: 0]
  119. --lossless Use lossless compression mode [boolean]
  120. --miniswhite Write 1-bit images as miniswhite [boolean]
  121. --minSize Prevent use of animation key frames to minimize file
  122. size [boolean]
  123. --mixed Allow mixture of lossy and lossless animation frames
  124. [boolean]
  125. --mozjpeg Use mozjpeg defaults [boolean]
  126. --nearLossless Use near_lossless compression mode [boolean]
  127. --optimise, --optimize Apply optimiseScans, overshootDeringing, and
  128. trellisQuantisation [boolean]
  129. --optimiseCoding, --optimizeCoding Optimise Huffman coding tables
  130. [boolean] [default: true]
  131. --optimiseScans, --optimizeScans Optimise progressive scans [boolean]
  132. --overshootDeringing Apply overshoot deringing [boolean]
  133. --palette Quantise to a palette-based image with alpha
  134. transparency support [boolean]
  135. --predictor Compression predictor
  136. [choices: "float", "horizontal", "none"] [default: "horizontal"]
  137. --preset Named preset for preprocessing/filtering
  138. [choices: "default", "photo", "picture", "drawing", "icon", "text"] [default: "default"]
  139. --pyramid Write an image pyramid [boolean]
  140. --quantisationTable, --quantizationTable Quantization table to use [number] [default: 0]
  141. --reuse, --reoptimise, --reoptimize Always generate new palettes (slow) [boolean]
  142. --resolutionUnit Resolution unit
  143. [choices: "cm", "inch"] [default: inch]
  144. --smartSubsample High quality chroma subsampling [boolean]
  145. --tileBackground Background colour, parsed by the color module
  146. [string] [default: rgba(255, 255, 255, 1)]
  147. --tileHeight Vertical tile size [number]
  148. --tileWidth Horizontal tile size [number]
  149. --trellisQuantisation Apply trellis quantisation [boolean]
  150. --xres Horizontal resolution [number] [default: 1.0]
  151. --yres Vertical resolution [number] [default: 1.0]
  152. Misc. Options
  153. -h, --help Show help [boolean]
  154. -v, --version Show version number [boolean]
  155. Examples:
  156. sharp -i ./input.jpg -o ./out resize 300 200 out/input.jpg will be a 300 pixels wide and
  157. 200 pixels high image containing a scaled and
  158. cropped version of input.jpg
  159. sharp -i ./input.jpg -o ./out -mq90 rotate 180 -- out/input.jpg will be an upside down, 300px
  160. resize 300 -- flatten "#ff6600" -- composite wide, alpha channel flattened onto orange
  161. ./overlay.png --gravity southeast -- sharpen background, composited with overlay.png with
  162. SE gravity, sharpened, with metadata, 90%
  163. quality version of input.jpg
  164. sharp -i ./input.jpg -o ./out --metadata Include all metadata in the output image
  165. sharp -i ./input.jpg -o ./out Set "IFD0-Copyright" in output EXIF metadata
  166. --metadata.exif.IFD0.Copyright "Wernham Hogg"
  167. sharp -i ./input.jpg -o ./out --metadata.density Set output metadata to 96 DPI
  168. 96
  169. For more information on available options, please visit https://sharp.pixelplumbing.com/

Input and output

  • The CLI supports input streams.
  • Glob patterns are allowed, for example --input './images/**/*.jpg'. Make sure you quote the pattern when using the CLI.
  • Supported output macros: {root}, {dir}, {base}, {name}, and {ext} (from Node.js path), for example: --output {dir} will overwrite original files.
  1. ┌─────────────────────┬────────────┐
  2. dir base
  3. ├──────┬ ├──────┬─────┤
  4. root name ext
  5. " / home/user/dir / file .txt "
  6. └──────┴──────────────┴──────┴─────┘
  • sharp - API for this module

Changelog

See the Changelog for a list of changes.

License

  1. The MIT License (MIT)
  2. Copyright (c) 2019 Mark van Seventer
  3. Permission is hereby granted, free of charge, to any person obtaining a copy of
  4. this software and associated documentation files (the "Software"), to deal in
  5. the Software without restriction, including without limitation the rights to
  6. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  7. the Software, and to permit persons to whom the Software is furnished to do so,
  8. subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in all
  10. copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  13. FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  14. COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  15. IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  16. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.