Jump to content


Getting/Setting file thumbnails with p4 attribute

thumb p4 command line

  • Please log in to reply
2 replies to this topic

#1 jwoelper

jwoelper

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 19 March 2018 - 12:37 PM

Hi everybody!

I am exploring custom thumbnails for files such as ai and obj. I have downloaded and tried p4thumb, but the supported filetypes are not enough for me, so I am searching for alternatives.
The documentation is a bit sparse, so I hope that some of you have more information.

p4thumb tells me the following: "P4Thumb converts Qt-supported image formats to a small PNG image." - so the format it produces seems to be a png - what might "small" mean in terms of resolution?

Further it states it "Sets thumbnail image attribute on compatible image files." What image files are compatible?


So far so good - I have read that I can use
p4 fstat -Oae -A thumb //depot/imageFile#rev
to see the thumbnail custom data.
source: http://answers.perforce.com/articles/KB/2926/?q=svn&l=en_US&fs=RelatedArticle

If I run this on a png file, it indeed lists attr-thumb and a value that looks like a hex dump of what might be a thumbnail. So maybe I can use custom tooling to write this data to another file, for example an adobe illustrator file?

According to the manual, p4 attribute reads data from stdin, so I saved the thumb attribute from a png to a text file and piped that to p4 attribute as follows:
cat out.txt | p4 attribute -e -n thumb -i test.ai
(-e is for hex data, -i is to read from stdin)

After submitting that file, test.ai now has an attr-thumb attribute that is identical to the png I copied it from. I would now assume p4v picks up that attribute and displays it in the preview tab - instead "No preview available for this item" is displayed.

Should this method work at all? Do I have to "tell" perforce somehow that it should use "attr-thumb" data for certain files? In the end, I would love if I could write a small application that could produce my own thumbnails and set them on a file. Does anyone have experience with this?

#2 Robert Cowham

Robert Cowham

    Advanced Member

  • PCP
  • 269 posts
  • LocationLondon, UK

Posted 25 July 2018 - 10:17 AM

Check out: https://www.perforce...4thumbnotes.txt

The above shows supported image formats.

Basically your method should work and you should be able to write your own plugin.

There might be finer details around the command to store/retrieve attributes.
Co-Author of "Learning Perforce SCM", PACKT Publishing, 25 September 2013, ISBN 9781849687645

"It's wonderful to see a new book about Perforce, especially one written by Robert Cowham and Neal Firth. No one can teach Perforce better than these seasoned subject matter experts"
  • Laura Wingerd, author of Practical Perforce, former VP of Product Technology at Perforce

#3 jwoelper

jwoelper

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 25 July 2018 - 12:13 PM

Thank you for your reply. I ended up doing that differently by just setting the hexadecimal attribute in python from a compatible png file. This was much faster than writing a plugin and allows supporting other file formats more easily. p4 attribute also requires a user with admin privileges or it will not work; also "view" > "show files as" "large thumbnails" gave me what I was looking for.


View PostRobert Cowham, on 25 July 2018 - 10:17 AM, said:

Check out: https://www.perforce...4thumbnotes.txt

The above shows supported image formats.

Basically your method should work and you should be able to write your own plugin.

There might be finer details around the command to store/retrieve attributes.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users