
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
A Ruby library to display and animate images in your terminal.
This library uses the MiniMagick gem, which requires ImageMagick or GraphicsMagick to be installed on your system.
You can install it for OS X with homebrew:
brew install imagemagick
See the requirements from MiniMagick for more installation info.
Add this line to your application's Gemfile:
gem 'cli_pix'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install cli_pix
Display an image from a file:
file_path = "demos/image.png"
image = CliPix::Image.from_file(file_path)
image.display
Display an image from a URL:
url = "https://f0.pngfuel.com/png/980/847/ruby-on-rails-logo-programming-language-rubygems-ruby-png-clip-art.png"
image = CliPix::Image.from_url(url)
image.display
Display animated gifs:
url = "https://media3.giphy.com/media/dXLnSpMDt7CvzRwMa9/giphy.gif?cid=ecf05e47nkii9rn5xq6uc0tsoyc53rowe8zjnwrcydkfbw6w&rid=giphy.gif"
image = CliPix::Image.from_url(url)
image.animate
Display data from a blob (to capture a webcam image, for example):
require "av_capture"
# uses av_capture gem to access webcam (OSX only)
session = AVCapture::Session.new
device = AVCapture.devices.find(&:video?)
session.run_with(device) do |connection|
# give a little time for the camera to warm up...
sleep 1
# run a loop continuously
loop do
# connection.capture returns a blob
image = CliPix::Image.from_blob(connection.capture, flop: true)
image.display
# wait for next capture
sleep 0.2
end
end
The CliPix::Image#display
and CliPix::Image#animate
methods will both output the image directly to your terminal. If you want more control, you can also use the CliPix::Image#read
method to return a string representation of the image a block:
url = "https://media3.giphy.com/media/dXLnSpMDt7CvzRwMa9/giphy.gif?cid=ecf05e47nkii9rn5xq6uc0tsoyc53rowe8zjnwrcydkfbw6w&rid=giphy.gif"
image = CliPix::Image.from_url(url, preprocess: true)
# read will yield an image_string of each frame of the image to the block
image.read do |image_string|
print `clear`
puts image_string
sleep 0.5
end
When creating an image, you can pass an options hash as a second argument. It takes the following options:
{
autoscale: true, # default: true. resize the image to fit the console window.
size: nil, # default: nil. you can provide an array of width and height [50, 30] or a string "50x30" to resize the image
flip: false, # default: false. if true, flip the image vertically
flop: false, # default: false. if true, flip the image horizontally
mode: :color, # default: :color. you can also use :ascii to display the image in ASCII mode.
preprocess: false # default: false. if true, process all frames of the image before displaying. useful for animated gifs.
}
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that cli_pix demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.