MCPcopy Create free account
hub / github.com/creatale/node-dv / readHeaderWebP

Function readHeaderWebP

deps/leptonica/src/webpio.c:165–198  ·  view source on GitHub ↗

! * \brief readHeaderWebP() * * \param[in] filename * \param[out] pw width * \param[out] ph height * \param[out] pspp spp (3 or 4) * \return 0 if OK, 1 on error */

Source from the content-addressed store, hash-verified

163 * \return 0 if OK, 1 on error
164 */
165l_int32
166readHeaderWebP(const char *filename,
167 l_int32 *pw,
168 l_int32 *ph,
169 l_int32 *pspp)
170{
171l_uint8 data[100]; /* expect size info within the first 50 bytes or so */
172l_int32 nbytes, bytesread;
173size_t filesize;
174FILE *fp;
175
176 PROCNAME("readHeaderWebP");
177
178 if (!pw || !ph || !pspp)
179 return ERROR_INT("input ptr(s) not defined", procName, 1);
180 *pw = *ph = *pspp = 0;
181 if (!filename)
182 return ERROR_INT("filename not defined", procName, 1);
183
184 /* Read no more than 100 bytes from the file */
185 if ((filesize = nbytesInFile(filename)) == 0)
186 return ERROR_INT("no file size found", procName, 1);
187 if (filesize < 100)
188 L_WARNING("very small webp file\n", procName);
189 nbytes = L_MIN(filesize, 100);
190 if ((fp = fopenReadStream(filename)) == NULL)
191 return ERROR_INT("image file not found", procName, 1);
192 bytesread = fread((char *)data, 1, nbytes, fp);
193 fclose(fp);
194 if (bytesread != nbytes)
195 return ERROR_INT("failed to read requested data", procName, 1);
196
197 return readHeaderMemWebP(data, nbytes, pw, ph, pspp);
198}
199
200
201/*!

Callers 1

pixReadHeaderFunction · 0.70

Calls 3

nbytesInFileFunction · 0.85
fopenReadStreamFunction · 0.85
readHeaderMemWebPFunction · 0.70

Tested by

no test coverage detected