Skip to main content

Ubuntu/Linux Fast Take Print Screen or Crop Screen Area Using scrot

Crop màn hình nhanh Ubuntu.

Với người dùng Windows, Mac hay Linux chụp toàn màn hình luôn có phím nhanh như Ctrl+PrintScr (Win), Mac là Cmd+Shift+3, Linux thường chỉ cần PrintScr.

Việc crop một vùng màn hình đôi khi rất hay dùng như muốn lấy ảnh nhanh chóng trên web, tạo ảnh tư liệu ... Với Mac OSX, chỉ cần nhấn 3 phím Cmd+Shift+4 rồi quét vùng muốn cắt. Window có snipping tool, nhưng có vẻ mặc định không có phím tắt nên phải thao tác nhiều như chọn vùng crop -> copy -> paste... Ubuntu cũng vậy, bạn có thể dùng phần mềm Shutter... nhưng thao tác không tiện lợi. Vì vậy mình làm 1 công cụ để giải quyết vấn đề này.

Ý tưởng đơn giản là thêm 1 shortcut key, rồi từ nó gọi 1 công cụ nào đó nhanh chóng hiện ra dấu + để quét vùng ảnh. Crop xong tự động lưu luôn, không cần thao tác gì nữa.
Ở đây mình dùng tool "import" của ImageMagick. Chi tiết về IM (imagemagick) các bạn có thể GG (google).

Thao tác:
1. Thêm keyboard shortcut: bạn vào prefrence ... --> Add custom keyboard: gõ tên và điền đường dẫn tới file bash chạy import.
Mình giữ nguyên shortkey như OSX: Ctrl+Shift+4 hay Window+shift+4 (bên OSX là Cmd).


2. Tạo file bash crop_area.sh rồi thêm 3 dòng sau:
#! /bin/bash
DATE=$(date +"%Y-%m-%d_%H_%M_%S")
import ~/bin/crop/$DATE.png


Ở đây mình tạo ở mục /home/nickfarrow/bin (bin là mục tự tạo).
/home/nickfarrow/bin

Thêm quyền chạy rồi tạo mục crop/ để lưu ảnh crop vào. 
Cuối cùng là chạy thử. Good luck.

Một số lưu ý:
- Crop area có vẻ không chuẩn nhất là nếu mở nhiều màn hình (monitor) và nhiều cửa sổ Nautilus.
- ImageMagick các bạn tự cài.
- Mình sẽ post các bài về ImageMagick và FFmpeg sau, 2 tool này rất mạnh cho xử lý ảnh + Video.


Update :
Khi thay lệnh import của ImageMagick trong bash script crop.sh bằng tool khác tên là SCROT  như sau:

#! /bin/bash
DATE=$(date +"%Y-%m-%d_%H_%M_%S")
scrot -s ~/bin/crop/$DATE.png
Thì lỗi crop sai layer window image hầu như không xuất hiện.

Comments

  1. Một số vđ như không nhấn ESC để thoát, vùng crop có lúc không chuẩn ... mình sẽ fix sớm.

    ReplyDelete
  2. https://bugs.launchpad.net/ubuntu/+source/imagemagick/+bug/1083128?comments=all

    This bug still open on launchpad. And the problem maybe with nautilus or import option;
    http://www.imagemagick.org/script/import.php

    ReplyDelete

Post a Comment

Popular posts from this blog

Rand mm 10

https://stackoverflow.com/questions/2447791/define-vs-const Oh const vs define, many time I got unexpected interview question. As this one, I do not know much or try to study this. My work flow, and I believe of many programmer is that search topic only when we have task or job to tackle. We ignore many 'basic', 'fundamental' documents, RTFM is boring. So I think it is a trade off between the two way of study language. And I think there are a bridge or balanced way to extract both advantage of two method. There are some huge issue with programmer like me that prevent we master some technique that take only little time if doing properly. For example, some Red Hat certificate program, lesson, course that I have learned during Collage gave our exceptional useful when it cover almost all topic while working with Linux. I remember it called something like RHEL (RedHat Enterprise Linux) Certificate... I think there are many tons of documents, guide n books about Linux bu

Martin Fowler - Software Architecture - Making Architecture matter

  https://martinfowler.com/architecture/ One can appreciate the point of this presentation when one's sense of code smell is trained, functional and utilized. Those controlling the budget as well as developer leads should understand the design stamina hypothesis, so that the appropriate focus and priority is given to internal quality - otherwise pay a high price soon. Andrew Farrell 8 months ago I love that he was able to give an important lesson on the “How?” of software architecture at the very end: delegate decisions to those with the time to focus on them. Very nice and straight-forward talk about the value of software architecture For me, architecture is the distribution of complexity in a system. And also, how subsystems communicate with each other. A battle between craftmanship and the economics and economics always win... https://hackernoon.com/applying-clean-architecture-on-web-application-with-modular-pattern-7b11f1b89011 1. Independent of Frameworks 2. Testable 3. Indepe