Skip to content

[feature request] Executable pdq CLI to come with library #11

@Dcallies

Description

@Dcallies

Hey @faustomorales - just adding this in case I send any Major League Hacking folks your way.

It would be convenient if installing this library also installed a simple CLI called pdq that behaved the following way:

$ pdq --help
usage: pdq file 
Hashes images with the PDQ algorithm.

Output format depends on the options:
  default: pdq hash in hex to stdout
  quality: pdq hash in hex, then a comma, then quality from 0-100
  dihedral: pdq hash in hex, space, then rotation name

options:
  -h, --help  show this help message and exit
  -d, --dihedral compute the 8 dihedral rotations
  -q, --quality include the quality in the output
  -l, --allow-low-quality don't abort if quality is low

$ pdq file.png
f8f8f0cee0f4a84f06370a22038f63f0b36e2ed596621e1d33e6b39c4e9c9b22

$ pdq -q file.png
f8f8f0cee0f4a84f06370a22038f63f0b36e2ed596621e1d33e6b39c4e9c9b22,100

$ pdq -d file.png
f8f8f0cee0f4a84f06370a22038f63f0b36e2ed596621e1d33e6b39c4e9c9b22 ORIGINAL 
1f70cbbc77edc5f9524faa1b18f3b76cd0a04a833e20f645d229d0acc8499c56 ROTATE90 
31ddf2513558de0ae56e4a8c8930cadde2ee084df3aed0a75fa512ea0e41e197 ROTATE180 
c79931968e880f4b97196df4d5ea0fb489b99e2c10af0dceacf572809b815ea5 ROTATE270 
aaca8605440c4a6735dbbf59b947df92e7bf161807e9cd88baf04579523098ab FLIPX 
559f78de2530abbdc663b131ed78f10072c4bb13f3acd6017d0e69150e413e5a FLIPY 
86a860c1f2bd1a1ec65cf4d10ab55087b4b89f7857da59bbd9200fd5845cc3f9 FLIPPLUS1 
5bb15db9e8a1f03c174a380a55aeaa2985bde9c60abce301bde48df918b5c15b FLIPMINUS1 

$ pdq -dq file.png
f8f8f0cee0f4a84f06370a22038f63f0b36e2ed596621e1d33e6b39c4e9c9b22,100 ORIGINAL 
1f70cbbc77edc5f9524faa1b18f3b76cd0a04a833e20f645d229d0acc8499c56,100 ROTATE90 
31ddf2513558de0ae56e4a8c8930cadde2ee084df3aed0a75fa512ea0e41e197,100 ROTATE180 
c79931968e880f4b97196df4d5ea0fb489b99e2c10af0dceacf572809b815ea5,100 ROTATE270 
aaca8605440c4a6735dbbf59b947df92e7bf161807e9cd88baf04579523098ab,100 FLIPX 
559f78de2530abbdc663b131ed78f10072c4bb13f3acd6017d0e69150e413e5a,100 FLIPY 
86a860c1f2bd1a1ec65cf4d10ab55087b4b89f7857da59bbd9200fd5845cc3f9,100 FLIPPLUS1 
5bb15db9e8a1f03c174a380a55aeaa2985bde9c60abce301bde48df918b5c15b,100 FLIPMINUS1 

$ pdq -q low_quality.png
image quality is too low (21)
# [ output is to stderr, Return code 3 ]

$ pdq -lq low_quality.png
facefacefacefacefacefacefacefacefacefacefacefacefacefacefaceface,29

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions