MCPcopy Create free account
hub / github.com/CodeCavePro/revitless-toolkit / ThumbnailExtractor

Class ThumbnailExtractor

src/Thumbnails/ThumbnailExtractor.cs:9–59  ·  view source on GitHub ↗

Extracts thumbnails from 3D models without relying on proprietary APIs.

Source from the content-addressed store, hash-verified

7 /// Extracts thumbnails from 3D models without relying on proprietary APIs.
8 /// </summary>
9 public abstract class ThumbnailExtractor
10 {
11 /// <summary>
12 /// Extracts thumbnail image to an array of bytes.
13 /// </summary>
14 /// <param name="stream">File stream.</param>
15 /// <returns>
16 /// Array of bytes containing thumbnail data.
17 /// </returns>
18 public abstract byte[] ExtractThumbnailBytes(Stream stream);
19
20 /// <summary>
21 /// Extracts thumbnail image to an array of bytes.
22 /// </summary>
23 /// <param name="bytes">Array of bytes to extract thumbnail from.</param>
24 /// <returns>
25 /// Array of bytes containing thumbnail data.
26 /// </returns>
27 public byte[] ExtractThumbnailBytes(byte[] bytes)
28 {
29 try
30 {
31 using var fileStream = new MemoryStream(bytes);
32 return ExtractThumbnailBytes(fileStream);
33 }
34 catch (Exception ex)
35 {
36 throw new InvalidOperationException("Failed to extract the thumbnail from an array of bytes.", ex);
37 }
38 }
39
40 /// <summary>
41 /// Extracts thumbnail to a stream.
42 /// </summary>
43 /// <param name="filePath">The path to file.</param>
44 /// <returns>
45 /// Array of bytes containing thumbnail data.
46 /// </returns>
47 public byte[] ExtractThumbnailBytes(string filePath)
48 {
49 try
50 {
51 var fileBytes = File.ReadAllBytes(filePath);
52 return ExtractThumbnailBytes(fileBytes);
53 }
54 catch (Exception ex)
55 {
56 throw new InvalidOperationException($"Failed to extract the thumbnail from the following file: '{filePath}'", ex);
57 }
58 }
59 }
60}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected