|
@@ -99,6 +99,27 @@ def prepare_real_name(name) |
|
|
end
|
|
|
end
|
|
|
|
|
|
+def load_pixbuf(info)
|
|
|
+ screen_name = info[:screen_name]
|
|
|
+ profile_image_url = info[:profile_image_url]
|
|
|
+ *profile_image_url_components = profile_image_url.split(/\//)
|
|
|
+ profile_image_last_component = profile_image_url_components.last
|
|
|
+ profile_image_url_components[-1] =
|
|
|
+ u(profile_image_last_component.gsub(/_normal\.([a-zA-Z]+)\z/, '.\1'))
|
|
|
+ profile_image_url = profile_image_url_components.join("/")
|
|
|
+
|
|
|
+ extension = $1
|
|
|
+ image_data = cache_file("images", "#{screen_name}.#{extension}") do
|
|
|
+ open(profile_image_url, "rb") do |image_file|
|
|
|
+ image_file.read
|
|
|
+ end
|
|
|
+ end
|
|
|
+ loader = Gdk::PixbufLoader.new
|
|
|
+ loader.write(image_data)
|
|
|
+ loader.close
|
|
|
+ loader.pixbuf
|
|
|
+end
|
|
|
+
|
|
|
def render_to_surface_big(surface, scale, paper, info, font)
|
|
|
margin = paper.width * 0.03
|
|
|
image_width = image_height = paper.width * 0.3
|
|
@@ -139,22 +160,7 @@ def render_to_surface_big(surface, scale, paper, info, font) |
|
|
context.move_to(margin, paper.height - layout.pixel_size[1] - margin)
|
|
|
context.show_pango_layout(layout)
|
|
|
|
|
|
- *profile_image_url_components = info[:profile_image_url].split(/\//)
|
|
|
- profile_image_last_component = profile_image_url_components.last
|
|
|
- profile_image_url_components[-1] =
|
|
|
- u(profile_image_last_component.gsub(/_normal\.([a-zA-Z]+)\z/, '.\1'))
|
|
|
- profile_image_url = profile_image_url_components.join("/")
|
|
|
-
|
|
|
- extension = $1
|
|
|
- image_data = cache_file("images", "#{screen_name}.#{extension}") do
|
|
|
- open(profile_image_url, "rb") do |image_file|
|
|
|
- image_file.read
|
|
|
- end
|
|
|
- end
|
|
|
- loader = Gdk::PixbufLoader.new
|
|
|
- loader.write(image_data)
|
|
|
- loader.close
|
|
|
- pixbuf = loader.pixbuf
|
|
|
+ pixbuf = load_pixbuf(info)
|
|
|
if pixbuf
|
|
|
context.save do
|
|
|
context.translate(paper.width - image_width - margin,
|
|
|
0 comments on commit
8007cc7