Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jPS9p-0002Ke-IS for pgsql-general@arkaria.postgresql.org; Fri, 17 Apr 2020 14:39:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jPS9J-0005mM-07 for pgsql-general@arkaria.postgresql.org; Fri, 17 Apr 2020 14:39:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jPS9I-0005kV-OK for pgsql-general@lists.postgresql.org; Fri, 17 Apr 2020 14:39:20 +0000 Received: from hermes.gatewaynet.com ([193.92.121.98]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jPS9F-0002ll-RI for pgsql-general@lists.postgresql.org; Fri, 17 Apr 2020 14:39:20 +0000 Received: from hercules.internal.net (hercules.internal.net [10.9.200.8]) by hermes.gatewaynet.com (8.15.2/8.15.2/Debian-8) with ESMTP id 03HEdFwK020456; Fri, 17 Apr 2020 17:39:15 +0300 Received: from [10.9.251.249] (dcmchgw.internal.net [10.9.0.1]) by hercules.internal.net (Postfix) with ESMTPS id 2C4211350B69; Fri, 17 Apr 2020 17:39:13 +0300 (EEST) Subject: Re: easy way to acquire height / width from images (PNG, JPEG) stored as bytea? To: pgsql-general@lists.postgresql.org References: <03a79221-6e00-4d8e-c6bc-c01cadb352d9@matrix.gatewaynet.com> Cc: itdev@gatewaynet.com From: Achilleas Mantzios Message-ID: <96fadd6d-d7f9-4365-d008-6ba25233c867@matrix.gatewaynet.com> Date: Fri, 17 Apr 2020 17:39:11 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------1CD585E804A555ADF3E4C718" Content-Language: en-US X-Virus-Scanned: clamav-milter 0.101.4 at hermes X-Virus-Status: Clean X-Spam-Status: No, score=2.0 required=5.0 tests=ALL_TRUSTED,DYN_SPAM_SUBJ, HTML_MESSAGE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on hermes.gatewaynet.com X-Synonym: Copied by Synonym dcm to: itdev@zimbra.gatewaynet, itdev@zimbra.gatewaynet List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------1CD585E804A555ADF3E4C718 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 17/4/20 4:09 μ.μ., Adam Brusselback wrote: > Why not extract and store that metadata with the image rather than > trying to extract it to filter on at query time? That way you can > index your height and width columns to speed up that filtering if > necessary. > Yes I thought of that, but those are coming automatically from our mail server (via synonym), we have written an alias : a program that parses and stores emails. This is generic, I wouldn't like to add specific code (or specific columns)  just for image attachments. However I dig the idea of the indexes. > You may be able to write a wrapper for a command line tool like > imagemagic or something so you can call that from a function to > determine the size if you did want to stick with extracting that at > query time. As I describe above, those attachments are nowhere as files. They are email attachments. Also we got about half TB of them. --------------1CD585E804A555ADF3E4C718 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

On 17/4/20 4:09 μ.μ., Adam Brusselback wrote:

Why not extract and store that metadata with the image rather than trying to extract it to filter on at query time? That way you can index your height and width columns to speed up that filtering if necessary.

Yes I thought of that, but those are coming automatically from our mail server (via synonym), we have written an alias : a program that parses and stores emails. This is generic, I wouldn't like to add specific code (or specific columns)  just for image attachments. However I dig the idea of the indexes.
You may be able to write a wrapper for a command line tool like imagemagic or something so you can call that from a function to determine the size if you did want to stick with extracting that at query time.
As I describe above, those attachments are nowhere as files. They are email attachments. Also we got about half TB of them.
--------------1CD585E804A555ADF3E4C718--