我用Rmagick裁剪图片然后用Prawn显示
以下是代码:
首先使用RMagick实例化图像的方法:
def build_magick_image(path)
if path.instance_of?(StringIO)
Magick::Image.from_blob(path.read)
else
Magick::Image.read(path)
end.first
end
在我的情况下,我有一个StringIO实例。 然后我裁剪图片:
img = build_magick_image(picture_path)
cropped_img = img.resize_to_fill(1735, 1560)
但现在我无法找到如何在我的Prawn pdf中显示它。 我的最后一次尝试是:
pdf.image cropped_img, at: [image_x, image_y], height: image_height.mm , width: inner_page_width.mm
但显然它不起作用。
有人可以帮助我吗?
谢谢:)
答案 0 :(得分:1)
当我试图弄清楚同一件事时,我发现了您的问题?这是我想出的解决方案:
将图像斑点包装在pgloader -D ./ -L load.log scripts/load-channel-tags.load
2020-03-06T19:24:27.015000Z LOG pgloader version "3.6.1"
2020-03-06T19:24:27.024000Z LOG Data errors in '/tmp/'
2020-03-06T19:24:27.024000Z LOG Parsing commands from file #P"/tmp/load-identifer-table.load"
; in: LAMBDA (PGLOADER.SOURCES::ROW)
; (VECTOR PGLOADER.USER-SYMBOLS::CREATED PGLOADER.USER-SYMBOLS::UPDATED
; PGLOADER.USER-SYMBOLS::ID PGLOADER.USER-SYMBOLS::GEO_ID
; PGLOADER.USER-SYMBOLS::REFERENCE_ID PGLOADER.USER-SYMBOLS::TAGGED_BY)
; --> MAKE-ARRAY MAKE-ARRAY LOCALLY
; ==>
; (VECTOR PGLOADER.USER-SYMBOLS::CREATED PGLOADER.USER-SYMBOLS::UPDATED
; PGLOADER.USER-SYMBOLS::ID PGLOADER.USER-SYMBOLS::GEO_ID
; PGLOADER.USER-SYMBOLS::REFERENCE_ID PGLOADER.USER-SYMBOLS::TAGGED_BY)
;
; caught WARNING:
; undefined variable: PGLOADER.USER-SYMBOLS::ID
;
; caught WARNING:
; undefined variable: PGLOADER.USER-SYMBOLS::TAGGED_BY
;
; compilation unit finished
; Undefined variables:
; PGLOADER.USER-SYMBOLS::ID PGLOADER.USER-SYMBOLS::TAGGED_BY
; caught 2 WARNING conditions
2020-03-06T19:24:27.398000Z WARNING Target table "\"public\".\"identifier_reference\"" has 2 indexes defined against it.
2020-03-06T19:24:27.398000Z WARNING That could impact loading performance badly.
2020-03-06T19:24:27.398000Z WARNING Consider the option 'drop indexes'.
2020-03-06T19:24:27.446000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.448000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.448000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.448000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.448000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.448000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.448000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.448000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.449000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.449000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.449000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.449000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.450000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.468000Z LOG report summary reset
table name errors rows bytes total time
----------------------- --------- --------- --------- --------------
fetch 0 0 0.008s
----------------------- --------- --------- --------- --------------
"public"."channel_tag" 24 0 0.066s
----------------------- --------- --------- --------- --------------
Files Processed 0 1 0.023s
COPY Threads Completion 0 2 0.102s
----------------------- --------- --------- --------- --------------
Total import time 24 0 0.125s
对象中,这将为Prawn提供所需的接口。在您的特定情况下:
Table "public.identifier_reference"
Column | Type | Collation | Nullable | Default
--------------+--------------------------+-----------+----------+-----------------------------------------
created | timestamp with time zone | | |
updated | timestamp with time zone | | |
id | integer | | not null | nextval('identifier_reference_id_seq'::regclass)
geo_id | character varying | | not null |
reference_id | integer | | not null |
tagged_by | character varying | | |
Indexes:
"identifier_reference_pkey" PRIMARY KEY, btree (id)
"identifier_reference_ids_unique_cons" UNIQUE CONSTRAINT, btree (string_identifier, reference_id)
Foreign-key constraints:
"identifier_reference_geo_id_fkey" FOREIGN KEY (geo_id) REFERENCES geo(id)
"identifier_reference_reference_id_fkey" FOREIGN KEY (reference_id) REFERENCES reference(id)