Verified Commit 0b1a9db8 authored by Hugo Kerstens's avatar Hugo Kerstens
Browse files

Remove notebook

parent 15bb4d7b
%% Cell type:code id: tags:
``` python
from zesje.factory import create_app
from zesje.image_extraction import extract_images_from_file as extract
from pikepdf import PdfError
app = create_app()
app.app_context().push()
```
%% Cell type:code id: tags:
``` python
for image, path, number, total in extract('/home/hugo/Downloads/Test_1-1 (7).zip', ['Test_1-1 (7).zip']):
print(f'[{number}/{total}] {path}')
print(f'\t{image}')
```
%% Output
[1/3] ['Test_1-1 (7).zip', '256x256/hp_logo.png']
<PIL.Image.Image image mode=RGB size=256x256 at 0x7F4F971FA310>
[2/3] ['Test_1-1 (7).zip', '256x256/logo.png']
<PIL.Image.Image image mode=RGB size=256x256 at 0x7F4F9717B850>
[3/5] ['Test_1-1 (7).zip', 'Test_1-1 (6).pdf', 1]
<PIL.Image.Image image mode=RGB size=2481x3508 at 0x7F4F9718A7F0>
[4/5] ['Test_1-1 (7).zip', 'Test_1-1 (6).pdf', 1]
<PIL.Image.Image image mode=RGB size=2481x3508 at 0x7F4F9718AFD0>
[5/7] ['Test_1-1 (7).zip', 'Test_flatten.pdf', 1]
<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=2481x3508 at 0x7F4F971225E0>
[6/7] ['Test_1-1 (7).zip', 'Test_flatten.pdf', 1]
<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=2481x3508 at 0x7F4F97122730>
[7/7] ['Test_1-1 (7).zip', 'newplot.png']
<PIL.Image.Image image mode=RGB size=700x450 at 0x7F4F9718A0A0>
%% Cell type:code id: tags:
``` python
for image, path, number, total in extract('/home/hugo/Downloads/Test_flatten.pdf'):
print(f'[{number}/{total}] {path}')
print(f'\t{image}')
```
%% Output
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-3-f60373259533> in <module>
----> 1 for image, path, number, total in extract('/home/hugo/Downloads/Test_flatten.pdf'):
2 print(f'[{number}/{total}] {path}')
3 print(f'\t{image}')
TypeError: extract_images_from_file() missing 1 required positional argument: 'file_info'
%% Cell type:code id: tags:
``` python
from pathlib import Path
```
%% Cell type:code id: tags:
``` python
encoded = Path('/home/hugo/Downloads/rle_8.hex').read_bytes()[1:-1]
encoded = bytearray(encoded)
width = 595
height = 842
bits = 8
```
%% Cell type:code id: tags:
``` python
def _get8bitMap(encodedImage):
imgMap = ""
newEncodedImage = list(encodedImage)
I = range(0, len(newEncodedImage), 9)
for i in I:
imgMap += '{0:08b}'.format(newEncodedImage[i])
for i in sorted(list(I), reverse = True):
del newEncodedImage[i]
return (imgMap, newEncodedImage)
def _decodeImage8bit(encodedImage, width, height, scanning):
decodedImage = []
imgMap, encImg = _get8bitMap(encodedImage)
for index, i in enumerate(imgMap):
if i == '1' and encImg[index] == 0:
break
if i == '1':
decodedImage.extend([encImg[index + 1]] * encImg[index])
elif imgMap[index - 1] != '1' or index == 0:
decodedImage.append(encImg[index])
return decodedImage
```
%% Cell type:code id: tags:
``` python
_decodeImage8bit(encoded, width, height, None)
```
%% Cell type:code id: tags:
``` python
def a(b=dict()):
return b
c = a()
print(c)
c['test'] = 1
c = a()
print(c)
```
%% Output
{}
{'test': 1}
%% Cell type:code id: tags:
``` python
c = a()
c['test'] = 1
a()
```
%% Output
{}
{'test': 1}
{'test': 1}
%% Cell type:code id: tags:
``` python
```
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment