小编Sam*_*ija的帖子

获取图像大小而不将图像加载到内存中

我知道您可以使用PIL以下列方式获取图像大小

from PIL import Image
im = Image.open(image_filename)
width, height = im.size
Run Code Online (Sandbox Code Playgroud)

但是,我想获得图像的宽度和高度,而不必将图像加载到内存中.那可能吗?我只对图像大小进行统计,不关心图像内容.我只想让我的处理更快.

python image image-processing

96
推荐指数
5
解决办法
4万
查看次数

Hadoop MapReduce在多列上进行流式排序

我有mapreduce输入,如下所示:

key1 \t 4.1 \t more ...
key1 \t 10.3 \t more ...
key2 \t 6.9 \t more ...
key2 \t 3 \t more ...
Run Code Online (Sandbox Code Playgroud)

我想按第一列排序,然后按第二列排序(反向数字).有没有办法实现这个Streaming MapReduce?

我目前的尝试是这样的:

hadoop jar hadoop-streaming-1.2.1.jar -Dnum.key.fields.for.partition=1 -Dmapred.text.key.comparator.options='-k1,2rn' -Dmapred.output.key.comparator.class=org.apache.hadoop.mapred.lib.KeyFieldBasedComparator -mapper cat -reducer cat -file mr_base.py -file common.py -file mr_sort_combiner.py -input mr_combiner/2013_12_09__05_47_21/part-* -output mr_sort_combiner/2013_12_09__07_15_59/
Run Code Online (Sandbox Code Playgroud)

但这是按键和秒的第一部分排序(但不是第二部分作为数字而是作为字符串排序).

关于如何对两个字段(一个数字和一个文本)进行排序的任何想法?

sorting hadoop

3
推荐指数
1
解决办法
2848
查看次数

标签 统计

hadoop ×1

image ×1

image-processing ×1

python ×1

sorting ×1