Slack Thumbnail url from Slack api for any file type like Image, Pdf, Audio, Video etc - thumbnails

I need to extract thumbnail url for any particular file.
while accessing the https://slack.com/api/files.list
I saw that for image thumbnail key asfiles : thumb_64, thumb_80, 360 type JSON keys
For pdf it is like
& similarly for other file type it has different different json key to find thumbnail.
So for every particular file type should i find thumbnail key manually. Any shortcut to find thumbnail key for all file type.
I need to pass my thumbnail url to some service no matter what kind of file it is.
Thanks!

The documentation for the file object type gives some information on this. But as you have already noticed, it doesn't mention PDF or other file types.
If a thumbnail is available for the file, the URL to a 64x64 pixel
will be returned as the thumb_64 prop.
The thumb_80 prop (when present) contains the URL of an 80x80 thumb.
Unlike the 64px thumb, this size is guaranteed to be 80x80, even when
the source image was smaller (it's padded with transparent pixels).
A variable sized thumb will be returned as thumb_360, with its longest
size no bigger than 360 (although it might be smaller depending on the
source size). Dimensions for this thumb are returned in thumb_360_w
and thumb_360_h.
In the case where the original image was an animated gif with
dimensions greater than 360 pixels, we also created an animated
thumbnail and pass it as thumb_360_gif.
Depending on the original file's size, you may even find a thumb_480,
thumb_720, thumb_960, or thumb_1024 property.
I did try looking through the Slack client's JS code (search for thumb_pdf in client-boot-imports.XXXX.min.js), and found a code block where it seems to be defining possible thumb_* keys. While it is not conclusive, you may look for these fields in the API response and fallback to a default image for each supported format.

Related

iTextSharp: change the order of objects in existing PDF

I'm dealing with a corporate report generating system that generates documents with stamps and signatures.
The sad thing is that the system is not able to place images below existing text and tables, so the jpg-stamps overlapping text look really odd and unrealistic. The system does not support images with transparency channel either.
I'm trying to fix things by first printing reports to PDF and then manipulating images sending all them to back (below text and other vector content) using iTextSharp. Finally the results are sent to a hardware printer.
All the images are stored in resources (XObjects).
The problem is that I have no idea how to manipulate PDF-objects z-order (creation order) with iTextSharp.
The current version (a c# COM-object/assembly) works as follows:
Build the list of references to existing images (reference, image bytes, image CTM) in a page loop with parser.ProcessContent()
Execute KillIndirect() on any reference found
Replace them with writer.AddDirectImageSimple() and blank image (with transparent mask)
Insert previously stored image bytes as images (taking CTM into account) with stamper, in GetUnderContent mode.
I wonder if is there a more simple solution without blank images, excess references etc.

Change small_image size Magento

I need to change the small image size on Magento community.
HereĀ“s why, it does not fit the global product window.
link here
I tried at \app\design\frontend\default\magik_pinstyle\template\catalog\product\list.phtml
and flushed the image cache but I does not work.
I can see it`s a 265px image but when I search for a resize(265) I dont find anything.
This would actually be located in app/design/frontend/default/magik_pinstyle/template/catalog/product/view/media.phtml. Copy the file over from app/design/frontend/base/default/template/catalog/product/view/media.phtml if you don't have it on your template. On line 68 (in the base media.phtml) you'll find this line:
$_img = '<img src="'.$this->helper('catalog/image')->init($_product, 'image')->resize(265).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" itemprop="image" />';
Your photos don't fit the frame because your .product-view .product-img-box .product-image CSS is set to 320x300px (width/height). If you want your pictures to fit, you need to make sure the resize is set to the same size of the frame, and you should probably square off your frame.
If you want the larger frame, change your image CSS to 320x320px or 300x300px and change the above line to resize(320) or resize(300), respectively.
If you want to keep the 265x265px image size, change your image CSS to 265x265px and leave it as is.
Edit
It is still using a file in 265x265px resize cache.
You should deliberately clear out everything in your /media/catalog/product/cache folder, first the media.phtml checks to see if a resize already exists and falls back to that. If one isn't found, then it runs the resize.
You are editing the file found in app/design/frontend/default/magik_pinstyle/template/catalog/product/view/media.phtml, correct? If altering the existing resize function doesn't work after completely emptying the cache you can add the ->resize(300) function to line 15:
$this->helper('catalog/image')->init($_product, 'image')->resize(300)
Lastly, if you have a custom lightbox or theme section in your settings, check for anything you may have missed to alternately set dimensions.
Make sure to refresh your cache, you should clear your image cache too.
I know that this is an old post but but I want to add something that seems to be left out off most of these responses, you must enlarge the container that the image is contained in otherwise the image will not be enlarged.
I followed the first part of Jason's answer above by going into
app/design/frontend/default/magik_pinstyle/template/catalog/
/view/media.phtml. Copy the file over from app/design/frontend
/base/default/template/catalog/product/view/media.phtm
and changing line 32 and 33 to
$bigImageX = 608; from $bigImageX = 308;
$bigImageY = 608; from $bigImageY = 308;
and nothing happened after flushing of the cache both magento nor browswer.
I then went into dev tools and enlarged the width of
<div class="produt-img-box">
which increased the size of the image to my desired size.
Just to be clear, I also had to shrink the size of the
<div class="product-shop"> to totally accomplish my goal of resizing the image.

Get larger (non-thumbnail) image for Facebook Graph Link object

Is there a way to get larger, non-thumbnail image for a link object? For example, given the link object https://graph.facebook.com/344600782244586, how can I get something larger than the thumbnail?
https://graph.facebook.com/344600782244586/picture does not work. It gives me the error "No node specified". Which means I can't use the type parameter.
The link object has a picture property with a value of http://external.ak.fbcdn.net/safe_image.php?d=AQAjeHBmdhzmBYB7&w=90&h=90&url=http%3A%2F%2Ftctechcrunch2011.files.wordpress.com%2F2012%2F03%2Fgf.jpg%3Fw%3D150. That will give me the thumbnail. I've tried just playing with the w and h values, but then Facebook just returns a 1x1 GIF.
My current approach is to pull out the url parameter and use that, but I'm wondering if there is a FB approach I can use.
seems there is a new "full_picture" field to ask for:
/posts?fields=full_picture
note that it's still not referenced, so I don't know if it's working at 100% and seems to be great for links but not pictures.
I personally combines 2 solutions:
if link I use full_picture field
<img src="[full_picture]" />
if picture (after asking for object_id field /posts?fields=object_id ) simply:
<img src="https://graph.facebook.com/[object_id]/picture" />
I kind of found a hack way to get the larger pic. If your image url ends in "_s.jpg", just replace the "_s" with "_b" and voila. Its a hack, that may not work tomorrow, but for now, it
does.
See below:
Small pic vs Big Pic
From the graph api
https://developers.facebook.com/docs/reference/api/
You can specify the picture size you want with the type argument, which should be one of square (50x50), small (50 pixels wide, variable height), normal (100 pixels wide, variable height), and large (about 200 pixels wide, variable height): https://graph.facebook.com/[INSERT ID HERE]/picture?type=large.

extract pdf formatting

hi guys working on a app which main work is pdf editing.
i understand Apple doesn't provide any api for editing the pdf. but my requirements are like that.
so i thought of extracting the whole contents of the pdf file and create a new pdf after editing. now i need to know how to extract the pdf formatting (header, footer, images, highlighting.,,)
im using Tj operators to extract the pdf text. which operators should i use to extract the other informations of pdf file.
thanks in advance.
Images are painted on the page using the Do operator. Its operand is the image name in the resources dictionary. The Do operator also paints form XObjects (self contained vector graphics) and these are stored also in the resources dictionary. The Subtype key in the image/form XObject dictionary gives you the object type: "Image" for images and "Form" for form XObjects.
The other elements are plain vector graphics and text, the PDF files do not have headers, footers, paragraphs, etc as standalone objects. What you see visually as a page header, inside the PDF file is just plain text painted at the top of the page.
Highlights can be plain semi-transparent yellow rectangles (these are no different from other rectangles on the page) or highlight annotations (these are available in page's Annots array).

How to slice text or html string into pages with iPhone SDK?

How to slice some text (html) string into number of pages to be possible read text as a book?
Thanks for suggestions.
Assuming you are happy recognising only a subset of HTML markup without CSS (here I assume <p/><b/><i/><br/> tags only plus <font size=/> for font size changes (with other attributes ignored), <img> tags for images with all but src,width,height ignored and accurate width and height mandatory with all other tags/attributes ignored):-
TidyLib seems to have an MIT license - http://tidy.sourceforge.net/#source
SAX parse the XHTML output of TidyLib using NSXmlParser into a custom object model (unless you are exclusively using later versions of iPhone OS with public builtin DOM parser API in which case just use a DOM object model).
Set up a state machine with a caret position at top left of page and initial font size and formatting, page number of 1, maximum height of glyphs/images in current line of zero, and empty list of page boundaries.
For each run of text or image in object model, apply pre-ceding font size/format modifications, measure text using iPhone text measurement calls, reducing text length (trim to nearest space or hyphen) until it fits on current line, and resetting caret to line beginning and continuing for line wraps, and apply following font size and formatting changes. Over-count the width and height of text by some factor in cases where this is found to be required to prevent page overflow in the actual page rendering engine (UIWebView; you will have to experiment to see what the factors in the rendering engine are). Record page boundary in list.
Convert objects between page boundaries to simplified XHTML for each page. You may wish to add some CSS at this point for example to format link colours. You will need to convert local references to anchors on another page to load the correct other page. Perhaps add page footer/header with page numbers (subtract size of these from page height in earlier steps).
Save XHTML as set of files.
In essence this will work as long as the source HTML is specially prepared to use a subset of HTML for your app. Any old HTML will not do, though it might perhaps not be completely useless to give a rough idea for previews in some instances for some files.
The description above assumes you throw away formatting like ALIGN= and tables. It really is a very basic approach and will not reproduce complex pages as originally designed! It might well not suit you!
Perhaps the files should be pre-processed before reaching the iPhones in the field but if the iPhone OS / WebView line-wrapping/test positioning behaviour changes, the best position for page breaks may change. So you may need to cut your pages smaller than you think they need to be to allow for some unexpected growth when the rendering engine changes. Hmm. Perhaps not an easy task!
I haven't even tried to analyse HTML tables... HTML is of course, in its non-restricted full glory enormously probably unmanageably complex.