Create thumbnails

functions

(** fontsize **)
fs=20;

(** time series **)
ops={
(*AxesOrigin->{0,0},*)
Frame->True,PlotStyle->Black,
FrameStyle->Directive[Black,AbsoluteThickness[1.5]],
(*ImagePadding->{{90,20},{80,10}},*)
LabelStyle->Directive[21,FontFamily->"Helvetica",Black],
(*AspectRatio->1/5,*)
ImageSize->{Automatic,700}
};
(*ll=Graphics[GeometricTransformation[{EdgeForm[Black],Opacity[0],CountryData[#,"SchematicPolygon"]&/@CountryData["Continents"]},RescalingTransform[{{-178.125,178.125},{-88.125,88.125}},{{0,96},{0,48}}]],PlotRangeClipping->True];
xticks={{12,-150},{24,-100},{36,-50},{48,0},{60,50},{72,100},{84,150}};*)
yticks={{10,50},{25,0},{40,-50}};
(** phase plane plot **)
plotops={
ContourStyle->Evaluate[{AbsoluteThickness[4],ColorData[1,#]}&/@{1,2}],
FrameStyle->Directive[Black,AbsoluteThickness[1.5]],
(*RotateLabel->False,*)
LabelStyle->Directive[24,FontFamily->"Helvetica",Black],
ImageSize->{Automatic,450},
Axes->True,
PlotRangePadding->None
};
coreTuned="/home/sonja/SimEnv_DynamicalCoreTuning/12_02_15_Eke_Tuned/Aeolus_96x48x5_Reduced_Nt:5_dt:3600s.nc";

main

(*directoriesCountries =Select[FileNames["/media/sonja/6EFE0DA2FE0D63A5/OpenCV/Google-Scraper/downloads/climate change/*","",Infinity],DirectoryQ]*)
directoriesAll =Select[FileNames["/media/sonja/6EFE0DA2FE0D63A5/OpenCV/Google-Scraper/downloads/climate change impacts/*","",Infinity],DirectoryQ]

outputpath = "/media/sonja/6EFE0DA2FE0D63A5/OpenCV/Google-Scraper/downloads/thumbnails/";
directoriesAll =Select[FileNames["/media/sonja/6EFE0DA2FE0D63A5/OpenCV/Google-Scraper/downloads/sus*/U*","",Infinity],DirectoryQ]
If[!DirectoryQ[outputpath],CreateDirectory[outputpath]];
maxSidelength = 200;
Do[

Print[dir];
imagepaths =FileNames[(dir<>"/*"<>#)&/@{".png",".jpg",(*".gif",*)".jpeg",".bmp"},"",Infinity];
listimageNames={FileBaseName[#],Import[#]}&/@imagepaths;

thumbnails=ImageResize[#,{maxSidelength}]&/@listimageNames[[All,2]];
Print[Length[thumbnails]];

countrySearchterm = FileNameSplit[dir][[-2;;-1]];
Print[countrySearchterm];
Print["Start Export"];
MapThread[Export[outputpath<>"thumbnail-"<>countrySearchterm[[1]]<>"-"<>countrySearchterm[[2]]<>"-"<>#1<>".jpg",#2]&,{listimageNames[[All,1]],thumbnails}];
,{dir,directoriesAll}]

json-file

jsonOld = Import["/media/sonja/6EFE0DA2FE0D63A5/OpenCV/Google-Scraper/logs/"<>searchterm[[1]]<>"*_"<>countries[[1]]<>"_*"<>".json"];

countries = {"Germany","South_Africa","Brazil","USA","Mexico","Hong_Kong","Taiwan","Norway","Vietnam","Thailand","Turkey", "Russia"};
languages = {"German","Afrikaans","Portuguese","English","spanish","traditional-Chinese","traditional-Chinese","Norwegian","Vietnamese","Thai","Turkish", "Russian"};
languagesShort={"de","af","pt","en","es","zh-TW","zh-TW","no","vi","th","tr","ru"};
searchterm = {"climate change","global warming","energy transformation","climate change adaptation","climate change impacts","climate change disaster","climate change risk","sustainability","climate change mitigation"};

csv[[Position[csv[[All,1]],"img_005_Germany_de_climate_change"][[1,1]],2]]

k=1;j=1;csv = Import["/media/sonja/6EFE0DA2FE0D63A5/OpenCV/Google-Scraper/downloads/wordclouds/" <> searchterm[[k]] <> "/CSV/wordcloud_" <> countries[[j]] <> "_" <> languagesShort[[j]] <>"_"<> searchterm[[k]] <>".csv"];

count = 0;
jsonfile=Reap[Do[

jsonOld = Import["/media/sonja/6EFE0DA2FE0D63A5/OpenCV/Google-Scraper/logs/"<>searchterm[[k]]<>"_"<>countries[[j]]<>"_"<>languagesShort[[j]]<>".json"];
csv = Import["/media/sonja/6EFE0DA2FE0D63A5/OpenCV/Google-Scraper/downloads/wordclouds/" <> searchterm[[k]] <> "/CSV/wordcloud_" <> countries[[j]] <> "_" <> languagesShort[[j]] <>"_"<> searchterm[[k]] <>".csv"];
Table[count++;Sow[{
"id"->count,
"local_thumbnailpath"  ->FileNameJoin[{"thumbnails","thumbnail-"<>searchterm[[k]]<>"-"<>countries[[j]]<>"_"<>languagesShort[[j]]<>"-"<>FileBaseName[jsonOld[[i,3,2]]]<>".jpg"}], 
"local_imagepath"  ->FileNameJoin[{"downloads/",searchterm[[k]],countries[[j]]<>"_"<>languagesShort[[j]],FileBaseName[jsonOld[[i,3,2]]]}],
"country"->StringReplace[countries[[j]],"_"->" "],
"language"->StringReplace[languages[[j]],"-"->" "],
"searchtermOfficialLanguage"->jsonOld[[i,12,2]],
"searchterm" ->searchterm[[k]],
(*access time*)
jsonOld[[i,1]],
(*height*)
jsonOld[[i,5]],
(*width*)
jsonOld[[i,10]],
(*image source*)
jsonOld[[i,8]],
(*machine learning detection*)
(*"image_detect"->csv[[Position[csv[[All,1]],FileBaseName[jsonOld[[i,3,2]]]][[1,1]],2]],*)
(*last modified*)
If[StringQ[jsonOld[[i,11,2]]],
(*if data[[2]] is string*)
timezoneF[b_]:=If[StringMatchQ[b,"*+0000*"],0,
If[StringMatchQ[b,"*+0200*"],2,
If[StringMatchQ[b,"*GMT-04:00*"],-4,
If[StringMatchQ[b,"*+0800*"],8,
If[StringMatchQ[b,"*+1000*"],10,
If[StringMatchQ[b,"*+0100*"],1]]]]]];
(*get time zone*)
timezone=timezoneF[jsonOld[[i,11,2]] ];
dateListReplaced = DateList[StringReplace[jsonOld[[i,11,2]],{"+0000"->"","+0100"->"","+0200"->"","+0400"->"","-04:00"->"","+0800"->"","+1000"->"","-0000"->""}]];
(*check whether date is in the history*)
If[dateListReplaced[[1]]≤ DateList[][[1]],
(*if data lies  in the history*)
If[TrueQ[timezone==Null],
(*if timezone is null*)
jsonOld[[i,11,1]]->DateString[dateListReplaced,{ "Year","/","Month","/","Day"}], 
(*if timezone is NOT null*)
dateObject = TimeZoneConvert[DateObject[dateListReplaced,TimeZone->timezone],$TimeZone];
jsonOld[[i,11,1]]->DateString[dateObject,{ "Year","/","Month","/","Day"}]]
(*if data lies NOT in the history*)
,jsonOld[[i,11,1]]->""]
(*if data is NOT a string*)
,jsonOld[[i,11,1]]->""]
}],
{i,1,Length[jsonOld]}
]
,{j,Length[countries]},{k,1Length[searchterm]}]][[2]];

wordcloud_Germany_de_climate change adaptation

"/media/sonja/6EFE0DA2FE0D63A5/OpenCV/Google-Scraper/downloads/wordclouds/climate change adaption/CSV/wordcloud_Germany_de_climate change adaptation.csv"

Export["/media/sonja/6EFE0DA2FE0D63A5/OpenCV/html/json-All1.json",jsonfile[[1]]]

jsonfile[[1,3794]]