Hello, I just learn about cython todays and im trying to play with it and now im trying to load and image from local storage with .pyx extension but it just return 4 bytes but when i try to load a .txt it works fine...
Here's the main .py
Here's the main .py
import pyximport; pyximport.install()
import test_c
def main():
file: bytes = test_c.req()
print(file)
if __name__=='__main__':
main()and Here's the test_c.pyx file:from libc.stdio cimport fopen, fread, fclose, fseek, ftell, SEEK_END, rewind
from libc.stdlib cimport malloc
cpdef req():
cdef long lSize
cdef char *buffer
fp = fopen('img.jpg', 'rb')
fseek(fp, 0, SEEK_END)
lSize = ftell(fp)
rewind(fp)
buffer = <char *>malloc(lSize)
fread(buffer, 1, lSize, fp)
fclose(fp)
return bufferand here's the result:Output:b'\xff\xd8\xff\xe0'
